Make the OpenAPINormalizer extensible#20995
Conversation
Add comment to force rebuild
| * @param visitedSchemas a set of visited schemas | ||
| * @return Schema | ||
| */ | ||
| protected Schema doNormalizeSchema(Schema schema, Set<Schema> visitedSchemas) { |
There was a problem hiding this comment.
thanks for the PR
which looks good overall
but what's the reason behind to further breaking down normalizeSchema with 1 additional function doNormalizeSchema?
There was a problem hiding this comment.
but what's the reason behind to further breaking down normalizeSchema with 1 additional function
doNormalizeSchema?
public Schema normalizeSchema(Schema schema, Set<Schema> visitedSchemas) {
has 2 purposes:
- check if not already processed
- perform the actual normalization
I want to be able to override the 2.
Another option is to keep the original normalizeSchema and be sure that all options can be overriden.
For example, there is a need to uncomment the handling of normalizeAdditionalProperties
if (schema.getAdditionalProperties() != null) {
normalizeAdditionalProperties(m, visitedSchemas);
}
or split the normalization of composed schema:
} else if (ModelUtils.isComposedSchema(schema)) { // composed schema
return normalizeComposedSchema(schema, schemaVisited);
}
and copy the content of the inner block to the new protected Schema normalizeComposedSchema() method
There was a problem hiding this comment.
ok. thanks for the explanation
i may rename the function 'doNormalizeSchema' with a better name later
There was a problem hiding this comment.
quick question
why not just override normalizeSchema and copy 1 (check if not already processed) in the overidden function?
There was a problem hiding this comment.
why not just override
normalizeSchemaand copy 1 (check if not already processed) in the overidden function?
The new implementation does exactly that.
Thanks for the suggestion.
| return new OpenAPINormalizer(openAPI, inputRules); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
one more thing. can you please update the doc with more info on NORMALIZER_CLASS? there's no doc at the moment for this new rule
|
thanks for the PR. let's give it a try have a nice weekend |
fix #20994
Allow configuration of the OpenAPINormalizer
New normalizer rule: NORMALIZER_CLASS to provide the class name of the extended OpenAPINormalizer.
Change the private modifiers to protected to allow overriding and extensions of behaviour.
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)