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

OpenApi won't Contains those Controllers If the Controller not starts with [ApiController] Attribute #58938

Open
1 task done
yangbocheng opened this issue Nov 14, 2024 · 1 comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi

Comments

@yangbocheng
Copy link

yangbocheng commented Nov 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Simply create a newest NET 9 aspnetcore webapi, then add Microsoft.AspNetCore.OpenApi and Scalar.AspNetCore. Then add a new Controller without [ApiController], this contoller's actions won't be included in openapi json

Expected Behavior

Controllers without [ApiController] should be included in openapi json

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

NET 9

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 Nov 14, 2024
@yangbocheng
Copy link
Author

yangbocheng commented Nov 14, 2024

The reason to not use the [ApiController] is : Need manual validate some form fields, or api parameters in Project
OpenApi won't Contains those Controllers If the Controller not starts with [ApiController] Attribute

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
  <PackageReference Include="Scalar.AspNetCore" Version="1.2.36" />
</ItemGroup>

so if remove the [ApiController] from Test1Controller.cs , then this won't show in openapi/v1.json
Image
Image
Image

@yangbocheng yangbocheng reopened this Nov 14, 2024
@martincostello martincostello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Nov 14, 2024
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 feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants