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

Better document/warn requirement for unsetting doc.Servers #882

Closed
jamietanna opened this issue Dec 1, 2022 · 0 comments · Fixed by #883
Closed

Better document/warn requirement for unsetting doc.Servers #882

jamietanna opened this issue Dec 1, 2022 · 0 comments · Fixed by #883

Comments

@jamietanna
Copy link
Member

In https://github.com/deepmap/oapi-codegen/blob/5a337911b060aad7130b05ad1819cfd3b73884f4/examples/petstore-expanded/gin/petstore.go#L26-L28, and other cases we're getting the Middleware

	// Clear out the servers array in the swagger spec, that skips validating
	// that server names match. We don't know how this thing will be run.
	swagger.Servers = nil

I recommend we log a warning if we see that Servers != nil.

This won't break anyone's builds or expectations if they're needing it, but will make it clear that this could be a problem.

It's a problem I've hit several times and so have others I've worked with, so we should try and preemptively alert folks!

jamietanna pushed a commit that referenced this issue Dec 1, 2022
It's a fairly common mistake when using the OpenAPI request validation
filter from kin-openapi to receive `no matching operation was found`
errors if using the `servers` directive in your OpenAPI specification.

This is a valid usescase, but you may not always want to be enforcing
the validation that the `Host` header matches one of the `servers`
mentioned in your specification.

This makes it clearer to operators that there may be a configuration
issue here, as a way to avoid as many folks falling into the same trap
that many have before.

This also provides an option to silence the warning, as logging out can
be annoying and costly.

Closes #882.
deepmap-marcinr pushed a commit that referenced this issue Dec 17, 2022
It's a fairly common mistake when using the OpenAPI request validation
filter from kin-openapi to receive `no matching operation was found`
errors if using the `servers` directive in your OpenAPI specification.

This is a valid usescase, but you may not always want to be enforcing
the validation that the `Host` header matches one of the `servers`
mentioned in your specification.

This makes it clearer to operators that there may be a configuration
issue here, as a way to avoid as many folks falling into the same trap
that many have before.

This also provides an option to silence the warning, as logging out can
be annoying and costly.

Closes #882.
adrianpk pushed a commit to foorester/oapi-codegen that referenced this issue Jan 16, 2024
It's a fairly common mistake when using the OpenAPI request validation
filter from kin-openapi to receive `no matching operation was found`
errors if using the `servers` directive in your OpenAPI specification.

This is a valid usescase, but you may not always want to be enforcing
the validation that the `Host` header matches one of the `servers`
mentioned in your specification.

This makes it clearer to operators that there may be a configuration
issue here, as a way to avoid as many folks falling into the same trap
that many have before.

This also provides an option to silence the warning, as logging out can
be annoying and costly.

Closes oapi-codegen#882.
adrianpk added a commit to foorester/oapi-codegen that referenced this issue May 31, 2024
It's a fairly common mistake when using the OpenAPI request validation
filter from kin-openapi to receive `no matching operation was found`
errors if using the `servers` directive in your OpenAPI specification.

This is a valid usescase, but you may not always want to be enforcing
the validation that the `Host` header matches one of the `servers`
mentioned in your specification.

This makes it clearer to operators that there may be a configuration
issue here, as a way to avoid as many folks falling into the same trap
that many have before.

This also provides an option to silence the warning, as logging out can
be annoying and costly.

Closes oapi-codegen#882.
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