kpramesh2212 / openapi-merger-plugin

A plugin to merge openapi v3 files
Apache License 2.0
20 stars 8 forks source link

unwanted `example: null` entries are added #21

Open ndr-brt opened 1 year ago

ndr-brt commented 1 year ago

When I try to merge some openapi files, where no example is present, an example: null is added, this causes issue because, e.g. swagger editor does not show the fallback representation (if the example for an array response body is missing it should show an array with the representation of the item, but it shows "null").

version used: 1.0.5

e.g. Using resolve, the POST /assets endpoint is represented this way:

  /v3/assets/request:
    post:
      description: Request all assets according to a particular query
      operationId: requestAssets_1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuerySpec'
      responses:
        "200":
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AssetOutput'
          description: The assets matching the query
        "400":
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ApiErrorDetail'
          description: Request body was malformed
      tags:
      - Asset

after the merge, the same definition becomes:

  /v3/assets/request:
    post:
      tags:
      - Asset
      description: Request all assets according to a particular query
      operationId: requestAssets_1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuerySpec'
      responses:
        "200":
          description: The assets matching the query
          content:
            application/json:
              schema:
                type: array
                example: null
                items:
                  $ref: '#/components/schemas/AssetOutput'
        "400":
          description: Request body was malformed
          content:
            application/json:
              schema:
                type: array
                example: null
                items:
                  $ref: '#/components/schemas/ApiErrorDetail'
ndr-brt commented 2 months ago

A solution to this is to force the io.swagger.parser.v3:swagger-parser version to 2.1.22