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

Getting invalid reference when used with flatten = true option #2109

Open
TharmiganK opened this issue Jul 8, 2024 · 0 comments
Open

Getting invalid reference when used with flatten = true option #2109

TharmiganK opened this issue Jul 8, 2024 · 0 comments

Comments

@TharmiganK
Copy link

TharmiganK commented Jul 8, 2024

Hi,

When I used the following OpenAPI specification file and try to get the OpenAPI object from the parser which is enabled with flatten option, the references created for inline object schemas are incorrect.

OpenAPI specification:

openapi: 3.0.1
info:
  title: SocialMedia
  version: 0.1.0
servers:
  - url: "http://{server}:{port}/socialMedia/v1"
    variables:
      server:
        default: localhost
      port:
        default: "8080"
paths:
  /admin.user:
    get:
      summary: Get admin user
      operationId: getAdminUser
      responses:
        "200":
          description: Ok
          content:
            application/json:
              schema:
                title: admin.user schema
                type: object
                required:
                  - email
                  - id
                  - name
                properties:
                  id:
                    type: integer
                    format: int64
                  name:
                    type: string
                  email:
                    type: string

Parser code:

String openAPIFileContent = Files.readString(definitionPath);
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
parseOptions.setFlatten(true);
SwaggerParseResult parseResult = new OpenAPIParser().readContents(openAPIFileContent, null, parseOptions);

The reference in the parsed object look like this: admin.user schema but it should be #/components/schemas/admin.user schema.

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