Created by: impl
For request bodies that are completely inlined into a path's operations, the inline model resolver correctly generates both a schema component and a requestBody component and adds $refs.
However, when an operation already contains an $ref to a requestBody that itself contains an inline schema, that schema was not being flattened to a separate component. This change adds a separate method to do such flattening and add an $ref if needed.
This fixes the dreaded error about a model having an unknown base type (with typically invalid code generated) in this situation.
I have included several tests to verify the corrected behavior, including one test each for the issues this fixes (I suspect there are more duplicates, but this is what I could find from an initial search). I know the issue-specific tests are a little redundant, but I wanted to make sure each was actually solved, as everyone's specs varied slightly.
Fixes #8605 (closed) Fixes #9123 Fixes #10435 (closed) Fixes #11811 (closed)
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.