-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[C#] Fixed invalid generation of C# children models in allOf clauses #1127
Conversation
…n property of CodegenModel when children models are added to the model. Changed the modelGeneric.mustache template to decide whether to include a base validation model (for children to inherit) based on the hasChildren property, and not the discriminator property.
…up-to-date, that are failing in CI. This partially reverts commit 2168df0.
@rubms Thanks for the contribution. I've tested it locally with the spec in the linked issue and verified the compilation errors before the fix are now resolved with this code change. @wing328 before merging, I wanted to get your take on the change. Moving from |
@jimschubert as discussed, it's a bug fix but we don't classify it as a breaking change. |
@rubms thanks again for the fix, which has been included in the v3.3.1 release: https://twitter.com/oas_generator/status/1052020299821080577 |
…dren models in allOf clauses (OpenAPITools#1127) * Run ./bin/utils/ensure-up-to-date to re-generate samples run in the CI. * Fixed issue OpenAPITools#1126. DefaultCodegen now sets the hasChildren property of CodegenModel when children models are added to the model. Changed the modelGeneric.mustache template to decide whether to include a base validation model (for children to inherit) based on the hasChildren property, and not the discriminator property. * Run the ./bin/utils/ensure-up-to-date script after fixing the issue OpenAPITools#1126 * Reverted modification in go samples, performed by ./bin/utils/ensure-up-to-date, that are failing in CI. This partially reverts commit 2168df0.
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.3.x
,4.0.x
. Default:master
.Description of the PR
Fixed the #1126 issue, that causes the auto-generated C# children models not to compile because they attempt to invoke a
BaseValidate
method in the parent model that is not implemented. In order to fix the issue:DefaultCodegen.java
now sets thehasChildren
ofCodegenModel
totrue
in models that have children.modelGeneric.mustache
now useshasChildren
, instead ofdiscriminator
, in order to decide whether to implement aBaseValidate
method (for children to run the parent model validations). In addition, now theBaseValidate
method of the parent is explicitly invoked (in order to prevent infinite recursion in models that are both, children and parents.c.c. Core (as
DefaultCodegen.java
has been modified).@wing328 (2015/07)
@jimschubert (2016/05)
@cbornet (2016/05)
@jaz-ah (2016/05)
@ackintosh (2018/02)
@JFCote (2018/03)
@jmini (2018/04)
c.c. C# @mandrean (2017/08) @jimschubert (2017/09)