mohsen1 / multi-file-swagger-example

Multi-file Swagger example
http://azimi.me/2015/07/16/split-swagger-into-smaller-files.html
168 stars 39 forks source link

Definitions 'ref' is injected, not referenced #1

Closed NadavK closed 5 years ago

NadavK commented 9 years ago

In your example, foo.yaml contains a reference to the user definition:

ref: '#/definitions/User'

but this gets resolved to the actual object definition

swagger: '2.0'
  /bar:
    get:
      responses:
        '200':
          description: OK
          schema:
            type: object
            properties:
              name:
                type: string
definitions:
  User:
    type: object
    properties:
      name:
        type: string

instead of just including the ref as I would expect (is my expectation erroneous?)

swagger: '2.0'
  /bar:
    get:
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/User'
definitions:
  User:
    type: object
    properties:
      name:
        type: string
mohsen1 commented 9 years ago

It's a limitation of json-refs. Please follow https://github.com/whitlockjc/json-refs/issues/27

dylan-colaco commented 6 years ago

Can this be done now?

dylan-colaco commented 6 years ago

It looks like json-refs can do it: https://github.com/whitlockjc/json-refs/issues/125

ClaudioConsolmagno commented 6 years ago

Reviving this somewhat old thread. What would it take to update the lib to the latest json-refs version? I could create a pull request to just update the version but is that going to be accepted?

mohsen1 commented 6 years ago

@ClaudioConsolmagno I'll happily a PR doing that!

ClaudioConsolmagno commented 5 years ago

@mohsen1 Took me a while but I finally created that PR (https://github.com/mohsen1/multi-file-swagger-example/pull/21). Didn't want to simply update the versions in case it broke other functionality so also added a lightweight regression test as well.