APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

Unable to dereference discriminator mappings #348

Closed RagaviMuthukrishnan closed 4 months ago

RagaviMuthukrishnan commented 4 months ago

Raising this issue to understand/get suggestions to check if it possible to dereference the discriminator mappings keywords like anyOf, oneOf, allOf from OpenAPI YAML to JSON using json-schema-ref-parser.

                "oneOf": [
                  {
                    "type": "object",
                    "description": "A response body contract for a folder workspace item.  A folder workspace item contains folder specific data for the generic WorkspaceItemResponse.",
                    "properties": {
                      "child_folder_workspace_item_ids": {
                        "description": "A list of child folder workspace item IDs",
                        "example": ["folder-101", "folder-102", "folder-103"],
                        "type": "array",
                        "items": { "type": "string" }
                      }
                    }
                  }]}

When i try to parse the OpenAPI YAML to JSON, my generated json response has got oneOf keyword in it. While i am validating this schema response through AJV validator, it throws me the following error

  {
    instancePath: '/favourites/0/workspace_item/additional_details',
    schemaPath: '#/properties/favourites/items/properties/workspace_item/properties/additional_details/oneOf',
    keyword: 'oneOf',
    params: { passingSchemas: [Array] },
    message: 'must match exactly one schema in oneOf'
  }
]

Is there a way to get this discriminator mapping keywords ignored/dereferenced while parsing in order to get rid of the error?

Appreciate your valuable feedback, thanks in Advance !!

RagaviMuthukrishnan commented 4 months ago

Resolved, my bad. My JSON is not valid, i corrected it and it is now working as expected, hence closing the issue.