apigee-127 / swagger-tools

A Node.js and browser module that provides tooling around Swagger.
MIT License
701 stars 373 forks source link

Reference to something two directories higher is not working #552

Open CsatariGergely opened 6 years ago

CsatariGergely commented 6 years ago

Hi, I have a strange issue with swagger-tools 0.10.1 . I'm using lots of references and especially lots of references from external files. Now I would like to use a reference from a file which is two directories up in the directory structure than the original file.

This is the situation:

tree
.
├── definitions
├── definitions.yaml
└── directory1
    └── directory2
        └── api-definition.yaml

$ cat definitions.yaml 
definitions:
  test:
      type: string

$ cat directory1/directory2/api-definition.yaml 
swagger: "2.0"

info:
  version: "2.3.0"
  title: test-api
  license:
    name: "nope"
    url: https://nope/

basePath: "/test/v1"

schemes:
  - https

consumes:
  - "application/json"
produces:
  - "application/json"

paths:
  '/test':
    #SOL003 location: 5.4.2
    post:
      description: "Test"
      parameters:
        - name: test
          description: test
          in: body
          required: true
          schema:
            $ref: "../../definitions.yaml#/definitions/test"
      responses:
        200:
          description: OK
          schema:
            type: string

$ swagger-tools  validate -v directory1/directory2/api-definition.yaml 

Validation Details:

  Swagger Version: 2.0
  Swagger file: directory1/directory2/api-definition.yaml

API Errors:

  #/paths/~1test/post/parameters/0/schema/$ref: Reference could not be resolved: ../../definitions.yaml#/definitions/test

1 error and 0 warnings
whitlockjc commented 6 years ago

Wild. I'll have to take a peek.