Skip to content

Commit 653ae1e

Browse files
authored
Add security schemes filter normalizer option (#23174)
* Implement `normalizer` for security schemes * Continue development * Implement new filter logic Add test for it Optimize old filter logic * Add unit test on joint logic with `SET_BEARER_AUTH_FOR_NAME` * Add docs * Remove security schemes without marking them `x-internal` * Clean up deleted security schemes references * Discard unnecessary changes * Fix typo * Fix test * Fix code review remarks * Fix code review remark * Fix code review remark * Clean up callbacks and web hooks * - Revert cleaning trailing white spaces from markdown file - Make the changes backward compatible with custom filters - Iterate over nested callbacks in path items
1 parent a091fce commit 653ae1e

4 files changed

Lines changed: 1129 additions & 88 deletions

File tree

docs/customization.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,28 @@ Into this securityScheme:
754754
type: http
755755
```
756756

757+
- `SECURITY_SCHEMES_FILTER`
758+
759+
The `SECURITY_SCHEMES_FILTER` parameter allows selective inclusion of API security schemes based on specific criteria. It removes security schemes that do **not** match the specified values, preventing them from being generated. All references to removed security schemes also deleted. Multiple filters can be separated by a semicolon.
760+
761+
### Available Filters
762+
763+
- **`key`**
764+
When set to `key:api_key|http_bearer`, security schemes **not** matching `api_key` or `http_bearer` will be marked as internal (`x-internal: true`), and excluded from generation. Matching operations will have `x-internal: false`.
765+
766+
- **`type`**
767+
When set to `type:apiKey|http`, security schemes **not** using `apiKey` or `http` types will be marked as internal (`x-internal: true`), preventing their generation.
768+
769+
### Example Usage
770+
771+
```sh
772+
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
773+
-g java \
774+
-i modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
775+
-o /tmp/java-okhttp/ \
776+
--openapi-normalizer SECURITY_SCHEMES_FILTER="key:api_key|http_bearer ; type:oauth2"
777+
```
778+
757779
- `SORT_MODEL_PROPERTIES`: When set to true, model properties will be sorted alphabetically by name. This ensures deterministic code generation output regardless of property ordering in the source spec.
758780

759781
Example:

0 commit comments

Comments
 (0)