question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Can't override servers url in path object

See original GitHub issue
Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0
Which Swagger-UI version? 3.4.0
How did you install Swagger-UI? Used the standalone dist bundle
Which browser & version? Chrome, latest
Which operating system? MacOS X

On this Swagger doc page about API Server and Basepath, 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.

(Ron said to file this issue as a bug.)

Here are steps to reproduce this issue.

  1. Copy the openapi yaml content here: 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
  1. Go to the Swagger online editor and paste in the yaml content.

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

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

  4. Click Try it out.

  5. In the parameters, enter the following:

    • for lat, enter 37.3708698
    • for lng, enter -122.037593
  6. 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"

Expected Behavior

The server url specified at the path level should override the global server url.

Current Behavior

The global server url is being used instead.

Context

The API I’m describing has different URLs for different endpoints. (The sample YAML here is not the actual API I’m working with – I just used it to demonstrate the issue.) Right now, if you try to execute one endpoint, it submits the wrong curl and errors out. You have to manually select a different server URL in the global servers dropdown, which is unintuitive given that our server urls don’t logically map to path names.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
DylanCcommented, Nov 16, 2017

I can also confirm this issue. The documentation here reports this as a feature available: https://swagger.io/docs/specification/api-host-and-base-path/

However, currently it does not work that way.

1reaction
shockeycommented, Dec 1, 2017

Implemented! See #3972 for a screenshot of this in action.

This will go live in tomorrow’s release. Thanks to @tomjoht and everyone else for pitching in here 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

NextJS deploy to a specific URL path - Stack Overflow
I could create the folder structure inside my "pages" directory and change all my elements to use this folder structure. |- pages |-...
Read more >
API Server and Base Path - Swagger
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. servers replaces the host ,...
Read more >
Error Messages | Maps JavaScript API - Google Developers
If you are NOT the website owner, there are no steps you can take to fix any of these errors. However, you may...
Read more >
"Windows cannot access the specified device, path, or file ...
Troubleshooting error message: Windows cannot access the specified device, path, or file. You may not have the appropriate permission to access the item....
Read more >
Resolve | webpack
object. Configure how modules are resolved. For example, when calling import 'lodash' in ES2015, the resolve options can change where webpack goes to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found