-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Make the OpenAPINormalizer extensible #20995
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. thanks for the explanation
i may rename the function 'doNormalizeSchema' with a better name later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just override
normalizeSchema
and 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)