Skip to content
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

[aspnetcore] Improve model inheritance support by including JsonSubTypes to properly handle serialization #8384

Merged
merged 3 commits into from
Feb 16, 2021

Conversation

goexplore
Copy link
Contributor

@goexplore goexplore commented Jan 8, 2021

Generator aspnetcore mustache templates is missing a mechanism that can support polymorphism(inheritance).
Serializing child types will end up as their base class without indicating known types to the base class.

This pull request will also be a fix for #7377

  • add package reference on JsonSubTypes in `Project.csproj.mustache
  • apply usage by including KnownSubTypes and discriminator in model.mustache

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto 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.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@goexplore goexplore changed the title Improve model inheritance support by including JsonSubTypes to properly handle serialization [aspnetcore] Improve model inheritance support by including JsonSubTypes to properly handle serialization Jan 8, 2021
@goexplore goexplore marked this pull request as ready for review January 8, 2021 19:20
@wing328
Copy link
Member

wing328 commented Jan 12, 2021

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@goexplore
Copy link
Contributor Author

@wing328, thanks for your review.
Any chance to review this pull request again? Account is now linked to the commit

@wing328 wing328 modified the milestones: 5.0.1, 5.1.0 Feb 8, 2021
@wing328
Copy link
Member

wing328 commented Feb 16, 2021

cc C# tech committee: @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02)

Copy link
Member

@wing328 wing328 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I've not tested it locally

@wing328 wing328 merged commit cd0ca65 into OpenAPITools:master Feb 16, 2021
@wing328
Copy link
Member

wing328 commented Mar 22, 2021

@goexplore thanks for the PR, which has been included in the v5.1.0 release: https://twitter.com/oas_generator/status/1373636654024380423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants