Skip to content

Omit key services with derived attribute from OpenAPI definitions #62946

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

Closed
wants to merge 1 commit into from

Conversation

stevendarby
Copy link

Omit key services with derived attribute from OpenAPI definitions

Instead of checking the attribute type is exactly FromKeyedServicesAttribute, it now checks if it's assignable to it, so that it also covers derived attributes.

Note, I find the relatively newer IsAssignableTo easier to follow than IsAssignableFrom so opted for that, and in a slightly opinionated way I changed the existing code on that line to use that too, for some local consistency. I hope that's ok.

Fixes #58739

@stevendarby stevendarby requested review from captainsafia, a team and halter73 as code owners July 26, 2025 21:03
@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 26, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 26, 2025
@stevendarby
Copy link
Author

Oops, I was slow off the mark and only just realised @martincostello already raised a PR for this. There are some more improvements to the tests than in my PR, so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Services injected with attribute derived from FromKeyedServicesAttribute appear as request body in swagger
1 participant