swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

ParseOptions.setResolve(true) eliminates response refs but not schema/requestBody refs

Open spacether opened this issue 2 years ago • 0 comments

ParseOptions.setResolve(true) eliminates (replaces) operation response refs but not requestBody refs or schema refs

swagger-parser version 2.1.1

sample spec: In the parsed results, the /user/logout response does not include the ref to SuccessDescriptionOnly I would expect the in-spec refs to be kept as-is as that is how component schemas and request bodies are handled. External refs I would expect to be resolved into in-spec $refs.

openapi: 3.0.0
info:
  description: blah
  version: 1.0.0
  title: OpenAPI Petstore
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
tags: []
paths:
  /user/logout:
    get:
      tags:
        - user
      summary: Logs out current logged in user session
      description: ''
      operationId: logoutUser
      responses:
        default:
          $ref: '#/components/responses/SuccessDescriptionOnly'
  /foo:
    get:
      responses:
        default:
          description: response
          content:
            application/json:
              schema:
                type: object
                properties:
                  string:
                    $ref: '#/components/schemas/Foo'
servers:
  - url: https://localhost:8080/{version}
    description: The local server
    variables:
      version:
        enum:
          - 'v1'
          - 'v2'
        default: 'v2'
components:
  responses:
    SuccessDescriptionOnly:
      description: Success
  schemas:
    Foo:
      type: object
      properties:
        bar:
          $ref: '#/components/schemas/Bar'
    Bar:
      type: string
      default: bar

Could a feature be added that only resolves file external references?

spacether avatar Nov 30 '22 00:11 spacether