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

OpenAPI 3.1.0 definition parser result drops the license identifier #2056

Open
tgtshanika opened this issue Feb 19, 2024 · 0 comments
Open

Comments

@tgtshanika
Copy link

I used following code snippet to parse the OpenAPI definition and prettyprint it to a json value. But it seems like that the license.identifier is dropped out from the resulting JSON.

Swagger parser 2.1.20

       String openApiFilePath = "<Path>/Petstore-3.1.0.yaml"; // Replace this with the path to your OpenAPI 3.1 specification file
        // Create a new instance of OpenAPIV3Parser
        OpenAPIV3Parser openAPIParser = new OpenAPIV3Parser();

        // Parse the OpenAPI specification
        SwaggerParseResult parseResult = openAPIParser.readLocation(openApiFilePath, null, null);
        String parser = Json.pretty(parseResult.getOpenAPI());

Sample openAPI spec

openapi: 3.1.0
info:
  title: Sample API
  version: 1.0.0
  description: This is a sample API specification with license identifier.
  license:
    name: Apache 2.0
    identifier: Apache-2.0
  contact:
    name: API Support
    email: [email protected]
    url: https://www.example.com/support
servers:
  - url: https://api.example.com/v1
paths:
  /users:
    get:
      summary: Retrieves a list of users
      responses:
        '200':
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: The user's ID
                    username:
                      type: string
                      description: The user's username

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