Add security schemes filter normalizer option#23174
Add security schemes filter normalizer option#23174limentas wants to merge 6 commits intoOpenAPITools:masterfrom
Conversation
Add test for it Optimize old filter logic
|
I found one logging issue and I would like to fix it since I touched this code. The problem is normalizer logs message like |
|
thanks for the draft. please put it on hold for the time being |
|
@wing328 any ideas on how to proceed with this feature? |
|
let me try to open a PR later this week... |
I take this as you don't like the proposal in this PR. This is fine. Just let me know if you need any help from my side. |
|
@limentas when you've time, can you please PM me via Slack to further discuss this? |
|
here is the link to join our slack: https://join.slack.com/t/openapi-generator/shared_invite/zt-36ucx4ybl-jYrN6euoYn6zxXNZdldoZA |
can you please elaborate on this one? I thought this should be done as part of the fix as the goal is remove the security definition (that the users do not want for whatever reasons) from the whole spec as if it has never been defined in the security schema section. |
I do not completely this one. Please elaborate. |
|
I think your PR is almost done so let's push it through the finish line (my approach is too idealistic so I don't think I've time to finish it) |
At this moment I remove security schemas definitions only from components->securitySchemes. But these schemas are referenced in top-level security declaration and also can be referenced in operations. For example in petstore example there is petstore_auth security schema. Let's say new filter removes it. Then this schema is referenced also in POST
If I remember correctly the problem is that FILTER logging is incorrect. |
This PR adds new normalizer option to remove unnecessary security schemes. I have decided to make it similar to
FILTERoption to have this functionality more universal and allow to filter schemes by name and by type.I have tried to follow DRY principle and uniform the logic with current
FILTERimplementation that's why it required to touch existent logic.I have also moved
FILTERparse logic outside loop to not repeat it every iteration.TODO:
SET_BEARER_AUTH_FOR_NAMEoptionmarked as internal only (x-internal: true) by the {} filterResolves #22954
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds
SECURITY_SCHEMES_FILTERto filtercomponents.securitySchemesby key or type and remove non-matching entries, reducing unused auth configs. Also refactors operation filtering for better performance and extensibility. Resolves #22954.New Features
SECURITY_SCHEMES_FILTERacceptskey:and/ortype:(e.g.,key:api_key1|api_key2;type:oauth2); non-matching schemes are removed fromcomponents.securitySchemes.SET_BEARER_AUTH_FOR_NAME: conversion to HTTP bearer happens before filtering.docs/customization.md.Refactors
FilterwithOperationsFilterand introduces sharedBaseFilterused by both operations and security-schemes filters.FILTERonce per normalization and improves error messages with clear usage and input.Written for commit 19dae24. Summary will update on new commits.