Openapi-specification: Is it possible to reference the servers object from another OpenAPI file?

Created on 6 Apr 2018  路  1Comment  路  Source: OAI/OpenAPI-Specification

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?

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nomadtechie picture nomadtechie  路  4Comments

kolisko picture kolisko  路  4Comments

duckladydinh picture duckladydinh  路  4Comments

rossi-jeff picture rossi-jeff  路  5Comments

niquola picture niquola  路  5Comments