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

RequestBody and Response Examples with relativePath are not resolved #2091

Open
ramahmoo opened this issue May 7, 2024 · 0 comments
Open

Comments

@ramahmoo
Copy link

ramahmoo commented May 7, 2024

We have OpenAPI 3.0.1 spec with examples on relative path, we want to generate a single API file while creating API spec artifact.

Our API Looks like as specified in OpenAPI spec
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.1.md#media-type-object

as spec stats that examples could be a map of example/reference values
image

{
  "application/json": {
    "schema": {
         "$ref": "#/components/schemas/Pet"
    },
    "examples": {
      "cat" : {
        "$ref": "./examples/pet/cat.json"
      },
      "dog": {
        "$ref": "./examples/pet/dog.json"
        },
      "frog": {
        "$ref": "./examples/pet/dog.json"
        }
      }
    }
  }
}

Source code to generate the single API

ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true); // not resolving relative path examples as expected, even with resolveFully
parseOptions.setValidateExternalRefs(true);

SwaggerParseResult result  = new OpenAPIV3Parser().readLocation(inputSpec, null, parseOptions);
result.getMessages().forEach(System.out::println);

Debugging in Intellij shows that ResolverCache.java was able to load the example ref but your code not assigning this as value to your Example.java, hence we see a lot of

attribute ..xxx is unexpected

At the end generated API does not have those example values.

Could you please check if it is a bug or we are missing something in our understanding?

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