Ask a Question

Multiple endpoints. No fixed server basepath. Trying to find a solution.

saumikdandapat
New Contributor

Multiple endpoints. No fixed server basepath. Trying to find a solution.

We have apis like this:

http://dictionary-get-api.content.geodeservice.dev.us-east-1.aws.fdscloud.io/api/v1/dictionary 

http://dictionary-getbyid-api.content.geodeservice.dev.us-east-1.aws.fdscloud.io/api/v1/dictionary?id=1&kwd=PEVC

http://dictionary-patch-api.content.geodeservice.dev.us-east-1.aws.fdscloud.io/api/v1/dictionary/3

For dev and prod server we just need to change only the part of the endpoint in bold.

 

As you can see there are no fixed basepaths. All endpoints are different. So in swagger documentation, we cant have a specific server name due to that.
So each endpoint should go at path level but we should have the endpoints at path level but path names should be like this '/api/v1/dictionary' starting with /.
How do i use swagger to document my APIs in this case. Please help me find a solution to my problem. 

Thanks
Saumik

2 REPLIES 2
KJans
New Contributor

Re: Multiple endpoints. No fixed server basepath. Trying to find a solution.

The Swagger spec supports overriding servers for a different path or operation level: see https://swagger.io/docs/specification/api-host-and-base-path/

for this quote and an example:


Overriding Servers
The global servers array can be overridden on the path level or operation level. This is handy if some endpoints use a different server or base path than the rest of the API. Common examples are:
  • Different base URL for file upload and download operations,
  • Deprecated but still functional endpoints.


 

mhiggins
Staff

Re: Multiple endpoints. No fixed server basepath. Trying to find a solution.

Does this help:

 

servers:

  - description: Live servers
    url: 'https://{host}/v1'
    variables:
      host:
        enum:
          - 'test.book.com'
          - 'staging.book.com'
          - 'sandbox.book.com'
       default: 'test.book.com'

cancel
Showing results for 
Search instead for 
Did you mean: