[core][java] allOf models keep the additionalProperties of their members
SE
2d ago+859+859+012345678901234567890123456789-17-17-01234567890123456789
An allOf model dropped the additionalProperties of its members: petstore's Cat has an Address member with integer values and got no map. When the model does not state the keyword itself, its members now decide: the value schema they agree on, otherwise any type. A child whose parent has the map inherits it, as okhttp-gson's x-inherits-additional-properties does. Only generators with supportsAdditionalPropertiesWithComposedSchema change.
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg @KannaKim @AndreyVMarkelov
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Summary by cubic
Fixes allOf models dropping the additionalProperties their members declare, so petstore's Cat now carries a map with the value type its Address member specifies.
- The composed schema's own
additionalPropertieskeyword wins over member declarations. - When members disagree, the value schema falls back to any type.
- A member stating
additionalProperties: falsevetoes the map, since allOf is an intersection. - Children inherit a parent's map instead of redeclaring their own.
- Only generators with
supportsAdditionalPropertiesWithComposedSchemachange.
Builders
- Java and Spring builder copy paths (
toBuilder()/copyOf()) now carry theadditionalPropertiesmap, including maps inherited from a parent.