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

API description provider not lifting Container type of properties #56764

Closed
1 task done
jgarciadelanoceda opened this issue Jul 12, 2024 · 4 comments
Closed
1 task done
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi
Milestone

Comments

@jgarciadelanoceda
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This bug comes from an issue we face using Swashbuckle. Analyzing the issue domaindrivendev/Swashbuckle.AspNetCore#2658, Swashbuckle is not capable of documenting the properties of a class that is used with AsParameters, because when checking the documentation Swashbuckle looks for the Container type and is not present in the documentation of the MetadataType

Expected behavior
To have documentation about the ContainerType to be able to set this documentation with Swashbuckle.

More info in microsoft/OpenAPI.NET#1712

cc:@captainsafia

Expected Behavior

Provide the ContainerType of the properties that come from a AsParameters class

Steps To Reproduce

Create an endpoint with AsParameter class and check if the ContainerType is present

Exceptions (if any)

No response

.NET Version

Dotnet8

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Jul 12, 2024
@captainsafia
Copy link
Member

@jgarciadelanoceda Thanks for filing this issue!

It appears that the issue is due to the fact that the ApiParameterDescription.ModelMetadata.ContainerType property isn't configued for ApiParameterDescriptions that are dervied from [AsParameters] types. The problem is with this method:

private static EndpointModelMetadata CreateModelMetadata(Type type) =>
new(ModelMetadataIdentity.ForType(type));

Which only passes information about the type, and not the property info when constructing model metadata. To fix this, we'd want to call the correct ModelMetadataIdentity API to get all the of the information funneled through.

If this is enough information to help you open a PR, I'd be glad to review it. Otherwise, I can share more pointers on how we might go about fixing this.

For now, sticking this in the backlog.

@captainsafia captainsafia added this to the Backlog milestone Aug 9, 2024
@captainsafia captainsafia added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Aug 9, 2024
@jgarciadelanoceda
Copy link
Contributor Author

Thank you @captainsafia.
I have been able to compile aspnetcore and I will try to handle the issue

@jgarciadelanoceda
Copy link
Contributor Author

I did not close it because I thought that this was going to net9 or net8, if it's planned to net10, then you can close this issue :)

@captainsafia
Copy link
Member

Yes, this will go into .NET 10. I don't think it's super urgent that we need to backport but if that is not the case let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants