APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

Token does not exist error #51

Closed TrueWill closed 4 years ago

TrueWill commented 4 years ago

swagger-cli validate (v4.0.4) is reporting

Token "Resource" does not exist.

I'm not sure why.

Our OpenAPI 3.0.3 document is very long; I think the relevant sections are

...
  "components": {
    "schemas": {
      "Foo": {
        "title": "Foo",
        "description": "A foo.",
        "type": "object",
        "properties": {
          "entry": {
            "description": "An entry.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "resource": {
                  "description": "The Resource for the entry.",
                  "$ref": "https://hl7.org/fhir/R4/fhir.schema.json#/definitions/Resource"
                },
...

Is an external URL $ref not supported, or is there something I'm doing wrong?

The error message doesn't include a line number, so it's difficult to be sure.

Thank you!

JamesMessinger commented 4 years ago

Yes, external URL $ref is supported. In this case, your $ref also includes a JSON Pointer to #/definitions/Resource, and the error is saying that Resource doesn't exist in that file