Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent processing of server variables in gorillamux router #706

Closed
slessard opened this issue Dec 14, 2022 · 1 comment · Fixed by #705
Closed

inconsistent processing of server variables in gorillamux router #706

slessard opened this issue Dec 14, 2022 · 1 comment · Fixed by #705

Comments

@slessard
Copy link
Contributor

I don't really know how to explain this issue. If an OpenAPI document has a server set to "/" then gorillamux router CANNOT find a route for a request. If an OpenAPI document has a server set to a single variable and that variable's default value is "/" then the gorillamux router CAN find a route for a request. It seems to me that these two server values should be the same when it comes to finding routes.

This issue is demonstrated in PR #705

Can you help me understand why these two test cases do not work the same?

slessard pushed a commit to slessard/kin-openapi that referenced this issue Dec 15, 2022
@slessard
Copy link
Contributor Author

I figured out the issue. There is a bug in the way routers/gorillamux/router.go handles a openapi3.Server that contains a single variable and nothing more.

Here are the two test cases:

  1. {server} <--- this is the case that was failing
  2. http://{server}

The purpose of the makeServers function is to evaluate a openapi3.Server, process its variables, if any, then build an instance of srv with the processed data. Previously these two cases used different code to build the srv instance. The fix was to make both these cases use the same code for building the srv instance.

Please see the fix in PR #705

@slessard slessard changed the title inconsistent handling of server values in gorillamux routing inconsistent processing of server variables in gorillamux router Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant