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

NSwag webapi2openapi not working in NSwag.MsBuild 14.0.7 #4897

Open
rajarathinam93 opened this issue May 16, 2024 · 5 comments
Open

NSwag webapi2openapi not working in NSwag.MsBuild 14.0.7 #4897

rajarathinam93 opened this issue May 16, 2024 · 5 comments

Comments

@rajarathinam93
Copy link

rajarathinam93 commented May 16, 2024

Hi,
I am migrating my app from .net 6.0 to .net 8.0.
I have a web api project in my solution which i am serving through orchestrator WebApp.
In the After-build event i was generating open api specification using NSwag webapi2openapi from the webapi assembly.

Now i see it's not supported anymore.

Can anyone help me with suitable solution or alternates.

Thanks!

@xC0dex
Copy link

xC0dex commented May 18, 2024

Hey, you can use the aspnetcore2openapi command instead.

@rajarathinam93
Copy link
Author

@xC0dex I tried that, it seems to be working, but not finding any api's.

Like i mentioned i have all my endpoints under core api project and that is not having any webhost, its a simple class library.

I am serving those api's through main WebApp.

Looks like after building Main webapp aspnetcore2openapi unable to find any api's. or am i missing something?

Also, When i tried aspnetcore2openapi command on core api project, its complaining for no webhost exists.

@rajarathinam93
Copy link
Author

@xC0dex/others - Any input on my above query.

@xC0dex
Copy link

xC0dex commented Jun 1, 2024

Hey @rajarathinam93, I think NSwag uses the ApiEndpointExplorer to get all the required information for building the OpenApi document. Does the Swagger UI contain all endpoints when you run the application when you run the WebApp? I guess you have to run the Nswag tool on the executable (In your case WebApp)

@rajarathinam93
Copy link
Author

rajarathinam93 commented Jun 3, 2024

@xC0dex - Thanks for the response.

NSwag does not generate endpoints on the executables of WebApp either.
Swagger UI of WebApp also not showing any of the endpoints.

var webApiAssembly = typeof(ApiControllerBase).Assembly; var mvcBuilder = services.AddMvc().AddApplicationPart(webApiAssembly);

This is how webapi project assemblies has been added into main WebApp

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

No branches or pull requests

2 participants