[Protobuf] Fix support for AllOf in protobuf-schema #7813
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. 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*
. For Windows users, please run the script in Git BASH.master
Description
This fix is in 2 steps:
Fixed index for vars in generated protobuf files
To ensure the backward compatibility between two schema generations, I'm fixing the index generated for each attribute base on its name.
Correct support of AllOf
As there is no inheritance in protobuf, the use case 3_0/allOf_composition_discriminator.yaml doesn't work.
If the parent is referenced in the response, we can't use one of its children as instantiation (Dog for Pet for example).
The only way to make it work is to replicate all attributes from the children in the parents, including imports.
Before the fix, the generated Pet was:
After the fix: