Forum Discussion

oleksiibulba's avatar
oleksiibulba
Occasional Visitor
2 years ago

Is possible to specify existing server object for a route

I have an `openapi.yaml` file with several server objects, for example:

openapi: '3.0.3'
servers:
- url: 'https://example.com/api/v1'
description: Legacy v1 server
- url: 'https://api.example.com/v2'
description: New REST API server
paths:
/users:
get:
description: This is an endpoint for getting users list
# other stuff

Is it possible to request changes to a specification, so I can add some sort of a key to indicate what endpoint should be used with the path?

For example:

servers:
legacy:
url: 'https://example.com/api/v1'
description: Legacy v1 server
rest:
url: 'https://api.example.com/v2'
description: New REST API server
paths:
/users:
get:
description: This is an endpoint for getting users list
servers:
- $ref: '#/servers/legacy'

If "servers" is presented in the path object, then only those servers are valid for the path.

No RepliesBe the first to reply