swagger-api / swagger-parser

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

url and identifier in the license field are handled incorrectly #1890

Closed bweben closed 1 year ago

bweben commented 1 year ago

Currently, swagger-parser will error with the following message attribute info.license.identifier is missing when parsing an OpenApi 3.1 document where license.url and license.name is set (see the example document below). According to the official OpenApi 3.1 schema it must have either the license.url or the license.identifier set but not both. This PR will fix swagger-parser to work according to the schema.

Example OpenApi 3.1 which currently fails:

openapi: 3.1.0
servers:
  - url: 'http://abc:5555/mypath'
info:
  version: '1.0'
  title: dd
  license:
    name: test
    url: http://example.com
paths:
  /resource1/Id:
    post:
      description: ''
      operationId: postOp
      responses:
        '200':
          description: Successful
        '401':
          description: Access Denied
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/mydefinition'
        required: true
components:
  schemas:
    mydefinition: {}

Link to the OpenApi 3.1 schema: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#licenseObject

frantuma commented 1 year ago

Thanks!