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 properties of complex type and navigation properties on complex types #158

Merged
merged 25 commits into from
Jan 19, 2022

Conversation

baywet
Copy link
Member

@baywet baywet commented Jan 6, 2022

fixes #15

This pull request adds path items for complex properties on entities as well as path items for navigation properties in complex types. Subsequently, it adds raw count, type cast and $ref path segments under those when required.
For a detail of which paths we're adding, see #15

@baywet baywet self-assigned this Jan 6, 2022
@baywet baywet added this to the 1.0.10 milestone Jan 6, 2022
baywet added 20 commits January 7, 2022 09:01
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
@baywet baywet marked this pull request as ready for review January 12, 2022 14:58
@baywet baywet enabled auto-merge January 12, 2022 14:58
.Where(CanFilter))
{
var count = _model.GetRecord<CountRestrictionsType>(np, CapabilitiesConstants.CountRestrictions);
RetrieveNavigationPropertyPaths(np, count, currentPath, convertSettings);
Copy link
Contributor

Choose a reason for hiding this comment

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

RetrieveNavigationPropertyPaths will throw an exception when calling ShouldExpandNavigationProperty since OdataSegment.EntityType is not yet implemented:

public virtual IEdmEntityType EntityType => throw new NotImplementedException();

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for reporting that, can you give it another try with this latest commit please?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's related but, a null exception is thrown when attempting to retrieve the "Entity type of a Complex type property segment" here:

if (navEntityType.IsAssignableFrom(segment.EntityType))

Example:
The complex property segment in question:
image

The complex type which has containment navigation properties
image

Copy link
Member Author

Choose a reason for hiding this comment

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

I've just pushed another commit that should solve your issue, please pull and give it another try.

@baywet baywet force-pushed the feature/nav-prop-complex-type branch from 5e5c41e to 104b4cb Compare January 18, 2022 17:51
OpenApiSchema schema = new OpenApiSchema
{
OpenApiSchema schema = new()
{
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

Copy link
Member Author

Choose a reason for hiding this comment

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

are you referring to the new() syntax?

@xuzhg
Copy link
Contributor

xuzhg commented Jan 18, 2022

Basically, it looks good to me.

@baywet baywet requested a review from xuzhg January 18, 2022 20:25
@baywet baywet disabled auto-merge January 19, 2022 12:50
@baywet baywet merged commit fb9e753 into master Jan 19, 2022
@baywet baywet deleted the feature/nav-prop-complex-type branch January 19, 2022 12:51
@darrelmiller
Copy link
Member

@baywet We cannot generate paths for properties that are complex types unless there is a specific annotation to indicate that the path is supported. It causes way too many paths to be generated.

@baywet
Copy link
Member Author

baywet commented Feb 3, 2022

@darrelmiller this PR resulted in a 3x path items increase.
https://github.com/microsoft/OpenAPI.NET.OData/pull/158/files#diff-fbd1ddb1a7f9b639e508912aeb20d5fa47fa88a3850b93aae4d81f82633cac39R51

(considering it might be impacted by inaccurate contains target attributes as well)

I'd be ok with having a default of "if there's no annotation saying it's supported, don't add anything" and this should be a quick change once we know which annotation to read in.

Which annotation should I read to implement that change?

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.

Support complex type with navigation property
5 participants