swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
780 stars 526 forks source link

OpenAPI 3.1.0 definition parser result drops the license identifier #2056

Open tgtshanika opened 7 months ago

tgtshanika commented 7 months ago

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: support@example.com
    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