Skip to content

Is it possible to reference the servers object from another OpenAPI file? #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iappa1 opened this issue Apr 6, 2018 · 1 comment
Closed

Comments

@iappa1
Copy link

iappa1 commented Apr 6, 2018

I'm documenting a list of APIs using OpenAPI 3.0 and a separate YAML file for each API.

All APIs use the same target server, so currently I have the following in each API definition:
`

  servers:
      - url: www.abc.com   
        description: "Production Server" 

`
But I don't want to repeat the servers in all API definitions. Instead, I would like to reference the servers from a single file, like so:

`

    //sample.yaml
     ...
    servers:
    $ref: 'index.yaml#/servers'

`

But Swagger UI shows the "Could not render this component" error.

Is it possible to $ref the servers in OpenAPI 3.0 definitions?

@webron
Copy link
Member

webron commented Apr 8, 2018

As you can see in the spec, the Servers Object does not support using references to other places, so indeed, at the moment, you'd have to copy the object between the definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants