-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Core] Add warning on headers with underscores #4412
[Core] Add warning on headers with underscores #4412
Conversation
Thanks for the PR. Instead of adding the warning in the default codegen, what about adding it to the PHP Slim 4 generator to start with? If I'm just using the documentation generator, I don't think the warning is relevant to me. |
@wing328 Hmmm, maybe you right. I've chosen default codegen because it's an api design problem, not framework. Wanted to hear other opinions, but your argument seems reasonable. I would add it to all server generators, but there is no What do you think about log message? Do you like it? Maybe I should remove stackoverflow link from it? |
This reverts commit 971f7707776aaa5c908767b3b96c81aea6a8086b.
This reverts commit d9d6716bf28f52725b4cb268b4ccb3474ce6ed1d.
This reverts commit 6e84d8f6dc28b602e39cdb204c1c6d2be85c642b.
This reverts commit 569180c3f06258b59fc55977e9fd9e7ea0a3c2e4.
0b8c2e0
to
bdf7d9e
Compare
Warning triggers only with server generators from now. |
bdf7d9e
to
f1d54fe
Compare
I think this would be better at spec validation, since users can skip those warnings. This is excellent quality of life improvement for the community. |
@jimschubert Do we have our own spec validator module/package? I used |
@ybelenko our validations are done ad hoc in the generate and validate tasks. See for example: Line 54 in de162f7
I created a simple validation framework in #3183 which I plan to consume in work done in the PR linked in that PR. I think I can move your validations when I do the validation extraction. |
Mind if we remove the security label on this PR and related issue? We should only use this for issues related to security of using the tool (e.g. CVE for Jackson Databind, see https://github.com/OpenAPITools/openapi-generator/issues?q=label%3A%22Issue%3A+Security%22+is%3Aclosed). This isn't related to issues with authorization defined in spec. |
@jimschubert So, what with this PR? Should I close it without merge? Btw, personally me, I usually skip warnings because they looks like debug logs right now. There is no color difference between |
@ybelenko Just reviewed the PR more in depth… Would it be possible to add a flag and display this message only once? Consider if someone has 100 endpoints with 3-4 headers per endpoint, all following this format which is valid according to RFC. That would be a ton of noise in the console, and would be frustrating for anyone not deploying to Apache/Nginx (e.g. standalone Spring Boot server). Other than that concern, I think this looks great and I appreciate the detailed message.
I think this would be somewhat low priority, but definitely something we could evaluate. |
I would add an option to turn this validation off completely. I filed this issue because I encountered this problem twice(every time like the first time, I didn't remember about Apache specifics and been frustrated). This PR heals my personal pain 😄 The other thing that drives me crazy is that Apache doesn't allow dashes or underscores in domain names... well I already forget which one, see. |
@ybelenko following up, what about William's suggestion to move this to PHP generators only, or my suggestion to move this out of code which will run for every operation to something like the custom validation? As the PR stands at the moment I think this will add too much noise and I'd like to avoid doing this since it's done similarly in many different places. For example, see these from ModelUtils and DefaultCodegen: |
@jimschubert I think this is up to you and @wing328.
I've never used that validator before, but it sounds like a good idea to me. |
I opened #4979 to move the recommendations from our validate command into new validator types, which will allow us to provide recommendations on OpenAPI Specification docs up front from each of our interfaces rather than just the CLI. Please check it out and let me know what you think. |
Included in #4979 |
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.Closes #4217
I didn't add any tests, because underscore search is pretty basic in current PR. I can add tests if necessary.
Examples of new warnings:
cc @OpenAPITools/generator-core-team