I have deployed a web service using Connexion and OpenAPI 3.0. I run it locally for debugging testing, and deploy it to a production server subsequently.
I am struggling with how to specify the server URLs properly in the OpenAPI file. All works as expected when I specify this:
servers:
- url: http://localhost:5000/basepath/v1
I can test it with a simple call:
curl -X POST "http://localhost:5000/basepath/v1/endpoint" -H "accept: application/json" -H "Content-Type: application/json" -d "..."
Same works on the production server:
curl -X POST "http://myserver.net/basepath/v1/endpoint" -H "accept: application/json" -H "Content-Type: application/json" -d "..."
However, I would like to specify the production server URL in order to make use of the full power of OpenAPI (e.g. the UI to generate cURL calls). So I add another url:
servers:
- url: http://localhost:5000/basepath/v1
- url: http://myserver.net/basepath/v1
When I call the service, however, the endpoint is no longer found on the production server:
curl -X POST "http://myserver.net/basepath/v1/endpoint" -H "accept: application/json" -H "Content-Type: application/json" -d "..."
{
"detail": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404,
"title": "Not Found",
"type": "about:blank"
}
I have verified so many times to make sure the calls are identical and that the added URL entry was the only change.
When I remove the localhost
line, it works neither locally nor on the production server.
I reckon this has to do with how Connexion reads the API specificiation and how it sets up the routing. The documentation about this is very sparse though, and I could not find other examples about the best practice with Connexion and OpenAPI 3.0.
Any hints what the best practices are and/or where to start debugging this issue?