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

Adds support for configuring the default value of derived types' @odata.type property #307

Merged
merged 16 commits into from
Nov 17, 2022

Conversation

irvinesunday
Copy link
Contributor

Fixes #304

This PR:

  • Adds support for setting the default value of the @odata.type property in the schema of derived types.
  • Adds a new convert setting for setting this default value. The default value is true, meaning the default value will always be emitted. If false the value will be set conditionally based on whether the derived type's base type is abstract (and not entity) and is referenced in the properties of a structural property or an action.
  • Updates existing tests and adds a new test to validate the above.

src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs Outdated Show resolved Hide resolved
andrueastman
andrueastman previously approved these changes Nov 14, 2022
Copy link
Member

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

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

Thanks for this!

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

thanks for taking the changes, one last thing

@irvinesunday
Copy link
Contributor Author

thanks for taking the changes, one last thing

From the issue description written by @andrueastman, I understood that we should check whether the type derives from an abstract type alongside the other 2 listed checks, else, we generate the default value by default (as is the current current case). Is this not the expectation?

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

thanks for taking the changes

@irvinesunday irvinesunday merged commit 5952515 into master Nov 17, 2022
@irvinesunday irvinesunday deleted the fix/is/odatatype-default-value branch November 17, 2022 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default presence of odata.type property in generated OpenAPI
3 participants