On this Swagger doc page about API Server and Basepath 
<https://swagger.io/docs/specification/api-host-and-base-path/>, the 
section on "Overriding Servers" says that I can specify different server 
URLs for different paths. However, when I execute an operation in Swagger 
UI (or in the online Swagger editor), the submitted curl request does not 
use the specified server url for that path. Instead, the curl request uses 
the global server url.

I hope I'm just coding something wrong in my specification file. Can you 
take a look at what I'm doing?

Here are steps to reproduce this issue. 

1. Copy the openapi yaml content 
here: 
http://idratherbewriting.com/learnapidoc/docs/rest_api_specifications/openapi_weather_multiple_servers.yml

Note that in the  /weatherdata path, I have a different server URL 
declared: 


  /weatherdata:
    get:
      tags:
        - Full Weather Data
      servers:
      - url: https://another.simple-weather.p.mashape.com


Did I do that correctly? I want this endpoint to use the url specified here 
rather than the global servers url.

2. Go to the Swagger online editor <https://editor.swagger.io/> and paste in 
the yaml content.


3. Click Authorize and paste in the shown API key.

4. Expand the weatherdata endpoint (this is the last one).

5. Click Try it out.

6. In the parameters, enter the following:


for lat, enter *37.3708698*

lng, enter *-122.037593*


7. Click Execute


The curl submitted shows this:


curl -X GET 
"https://simple-weather.p.mashape.com/weatherdata?lat=37.3708698&lng=-122.037593";
 -H "accept: application/json" -H "X-Mashape-Key: 
EF3g83pKnzmshgoksF83V6JB6QyTp1cGrrdjsnczTkkYgYrp8p"

It should show the other server url instead:


curl -X GET 
"https://another.simple-weather.p.mashape.com/weatherdata?lat=37.3708698&lng=-122.037593";
 -H "accept: application/json" -H "X-Mashape-Key: 
EF3g83pKnzmshgoksF83V6JB6QyTp1cGrrdjsnczTkkYgYrp8p"

Am I doing something wrong in the way I'm overriding the server URL for this 
endpoint? Or is this a bug?


Thanks,


Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to