Xavier W.
Xavier W.

Reputation: 1360

Swagger schema reference in another file

I'm working on huge yaml schema when I'm designing my swagger API service model and emphasized textI would like to save the model part in another file in order to have more flexibility and lisibility.

Following this documentation, I used this part of code :

components:
  schemas:
    Request:
      title: Request
      type: object
      properties:
        technicalData:
          $ref: '../../schemas/foo.yaml/components/schemas/TechnicalData'

And in my foo.yaml file, I have stuff like this :

components:
  schemas:
    TechnicalData:
      type: object
      properties:
        application:
          type: string
        applicationCode:
          type: string
        userId:
          type: string

It works on localhost, but I face the following issue running my file on the enterprise deployement server :

Errors Resolver error at components.schemas.Request.properties.technicalData.$ref Could not resolve reference because of: Not Acceptable

I am sucessfully able to browse my file through the browser locally.

Checking on the internet, I found some issue related to my topic, but unfortunately not very usefull : https://github.com/swagger-api/swagger-editor/issues/1561

https://github.com/RepreZen/KaiZen-OpenAPI-Editor/issues/438

Upvotes: 6

Views: 10052

Answers (1)

Helen
Helen

Reputation: 97590

Add # between the file name and /components/...:

$ref: '../../schemas/foo.yaml#/components/schemas/TechnicalData'
                             ^

Upvotes: 13

Related Questions