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

Discriminator mapping refs (anyOf) & callback refs not processed #2086

Open
anthochristen opened this issue May 1, 2024 · 4 comments
Open

Comments

@anthochristen
Copy link

When relative paths are used in discriminator mappings (anyOf) & callbacks the references are not processed.

Discriminator Mapping Ref sync issue:

  "requestBody": {
      "required": true,
      "content": {
          "application/json": {
              "schema": {
                  "anyOf": [
                      {
                          "$ref": "../components/schemas/adoption_request_for_bird.json"
                      },
                      {
                          "$ref": "../components/schemas/adoption_request_for_cat.json"
                      }
                  ],
                  "discriminator": {
                      "propertyName": "animal_type",
                      "mapping": {
                          "BIRD": "../components/schemas/adoption_request_for_bird.json",
                          "CAT": "../components/schemas/adoption_request_for_cat.json"
                      }
                  }
              }

In this case post the parsing the anyOf schemas becomes #/components/schemas/adoption_request_for_bird but the disciminator mapping still remains as ../components/schemas/adoption_request_for_bird.json. However the same works for OneOf.

Callback Ref issues:

{
  "{$request.body#/callback_url}/start": {
    "put": {
      "summary": "Does a callback",
      "description": "You know what it does",
      "requestBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "../../../schemas/payload.json"
            }
          }
        }
      },
      "responses": {
        "204": {
          "description": "Your server implementation should return this HTTP status code if the data was received successfully."
        }
      }
    }
  }
}

In this case the payload schema is incorrectly searched from the openapi.json base path instead of the relative path from the callback. Also this (looking in base path instead of relative path) seems to occur for parameter examples too.

@anthochristen
Copy link
Author

The relative refs issue in callbacks & parameter examples can be worked around by changing the ref path to be relative from base directory, instead of current directory.

But the Discriminator mapping ref issue breaks codegen, it is not able to resolve the Type. And creates some ERRORUNKNOWN class and compilation fails.

@anthochristen anthochristen changed the title Discriminator refs & callback refs not processed Discriminator mapping refs (anyOf) & callback refs not processed May 1, 2024
@anthochristen
Copy link
Author

@frantuma any updates on the PR for this issue?

@anthochristen
Copy link
Author

These issues are not present in the npm swagger-parser library.

@anthochristen
Copy link
Author

@frantuma / @gracekarina, Can you help check if #2087 help solve this as expected?

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