swagger-api / swagger-api/swagger-parser

OpenAPI 3.1.0 definition parser result drops the license identifier

Open
#2,056 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OpenAPIV3Parser.readLocation and the conversion represented by Json.pretty(parseResult.getOpenAPI()), using the supplied OpenAPI 3.1.0 YAML as the reproduction case. Trace how info.license.identifier is parsed and serialized, then verify that the identifier remains in the resulting JSON.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.