APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

Error resolving token when using dereference flag #19

Closed aaronschwartz closed 6 years ago

aaronschwartz commented 6 years ago

Thanks for your work on this library.

I'm running into a weird issue.

Here's my setup:

index.yaml

swagger: '2.0'

info:
  version: "1.0.0"
  title: "Test"
paths:
  /apiversion:
    get:
      tags:
        - Version
      security: []
      description: |
        This is a dedicated endpoint for determining the API version the unit adheres to.

        * This endpoint will always exist.
        * This endpoint will not require authentication.
      responses:
        200:
          description: Successful response
          schema:
            $ref: '#/definitions/ApiVersionInfo'
  $ref: 'separate.yaml#/paths'
definitions:
  ApiVersionInfo:
    type: object
    properties:
      apiVersion:
        type: string

separate.yaml

paths:
  /test:
    get:
      description: |
        Test Edpoint
      summary: |
        Test Edpoint
      responses:
        200:
          description: Successful response
          schema:
            $ref: '#/definitions/TestEndpointGet'
definitions:
  TestEndpointGet:
    type: object
    properties:
      test:
        type: integer

When I run the following command it appears to generate the correct file: npx swagger-cli bundle -t yaml -o test.yaml index.yaml

But when I add the dereference flag: npx swagger-cli bundle -t yaml -o test.yaml -r index.yaml

I get the following output:

Error resolving $ref pointer "...separate.yaml#/definitions/ApiVersionInfo". 
Token "ApiVersionInfo" does not exist.
JamesMessinger commented 6 years ago

Hi @aaronschwartz 👋 Thanks for reporting this issue.

This is a bug in json-schema-ref-parser, which is another project of mine that's used under-the-hood by Swagger CLI. So I've moved this issue to that repo