Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve reference from id #192

Open
grosswilerp opened this issue Feb 3, 2022 · 0 comments
Open

Can't resolve reference from id #192

grosswilerp opened this issue Feb 3, 2022 · 0 comments

Comments

@grosswilerp
Copy link

Since Apikana now creates schema draft7 it replaces the id with $id and now the validation fails when using references inside definitions that use $id. However, the JSON schema itself is actually valid, but it seems that ajv is not able to compile it properly.

Here is an example schema:

{
  type: "object",
  $id: "test",
  properties: {
    foo: {type: "integer"},
    bar: {type: "string"},
    "spec": {
        "$ref": "#/definitions/TopicSpecDescriptor",
        "description": "Topic specification."
    }
  },
  definitions: {
    "TopicSpecDescriptor": {
        "type": "object",
        "properties": {
            "partitions": {
              "$ref": "#/definitions/Int",
              "description": "Number of partitions.\nNormally 10.\nSee <a href=\"https://kafka.apache.org/documentation/#intro_concepts_and_terms\" target=”_blank”>Kafka concepts and terms</a>"
            }
        },
        "$id": "TopicSpecDescriptor"
    },
    "Int": {
        "type": "integer"
    }
  },
  required: ["foo"],
  additionalProperties: false
}

It validates without any error on JSON Schema Validator but when using ajv, it fails with this error:

  missingRef: 'TopicSpecDescriptor#/definitions/Int',
  missingSchema: 'TopicSpecDescriptor' 

If I remove the $id from the schema, it works as usual. But I don't think that's a good approach, especially since Apikana creates the JSON schema using $id now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant