-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
protoc-gen-swagger: support generating a Swagger definition with no schemes #1069
Comments
Thanks for raising this, seems a reasonable suggestion. I think in this case it probably wouldn't be harmful to change the default from I think changing the default should be reasonably straightforward, but let me know if you need anymore pointers. CC @ivucica |
Changing the default to There is a chance this could break existing users if they somehow rely on the |
You have reminded me about a slight concern - what about code generators? The spec says to use the scheme which the schema is accessed on, but for generators that will likely be the file system itself. Could you maybe look into how a few popular static swagger API generators handle an empty scheme? If they all handle an empty scheme well then I think we can go ahead with that change. |
I'm not sure which code generators are the most popular but I'll try these and report back:
Let me know if I missed one you think is important. |
Those 3 sound perfect 👍. |
I tested the code generators. All of them were able to generate code when loading a definition having no
I only tested client code generation; I assume that if someone is using What do you think? |
The go-swagger behaviour is somewhat concerning, since it's unsafe by default. This may be something we can raise with the go-swagger project though and shouldn't be a blocker for this change. I'm still happy for us to change the default, since it shouldn't, according to the spec, imply unsafe by default. Let me know if you need any help with the pull request. Could we raise an issue with the go-swagger project as well to see if they can change their behaviour (or we can change it for them 🙂)? |
Thanks @johanbrandhorst! I made a pull request. Let me know if I missed something or need to change anything.
Sure! I'll make an issue and reference this one from it. |
Make it so if you do not specify the schemes then no schemes will be present in the generated Swagger definition. The OpenAPIv2 spec says this means to use the same scheme that was used to access the Swagger definition itself. Fixes #1069
Make it so if you do not specify the schemes then no schemes will be present in the generated Swagger definition. The OpenAPIv2 spec says this means to use the same scheme that was used to access the Swagger definition itself. Fixes grpc-ecosystem#1069
It would be nice if
grpc-gateway
supported generating a Swagger definition with noschemes
key. According to the openapiv2 spec this means the following:This is currently not possible because the default schemes is
["http","https"]
and this default is only overridden when there is at least one scheme sepecified.I'm willing go contribute a change for this but I'd like some guidance on how to proceed. I can think of a few ways to do this:
UNKNOWN
values and thus make the list[UNKNOWN]
mean no schemes. This is kind of hacky. Arguably it would be better forprotoc-gen-swagger
to error out if it hitsUNKNOWN
since it is the fallback for unknown enum values. Right nowUNKNOWN
will be written to the definition as "unknown" which is not valid.EMPTY
) that explicitly means there are no schemes.schemes
is set to disable the default value. E.g. (bool schemes_set = 105
).Or if there is another way I didn't think of let me know!
The text was updated successfully, but these errors were encountered: