-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
OpenApiGenerateDocumentsOnBuild not working with .net 6 minimal api ? #2350
Comments
I'm seeing the same problem with .NET 6.0 minimal APIs. My guess is that this is caused by this line and declared as a dependency here. It appears that Microsoft.Extension.ApiDescription.Server version 3.0.0 doesn't support minimal apis. I manually installed 6.0.2 and ran the included Update: adding a direct package reference to |
Yes, it solved my problem ! |
Same problem. Also, I'd like to have a better way to override the host. I know that we can use SwaggerHostFactory or SwaggerWebHostFactory but, now with minimal apis, there's no Startup.cs, and I'd rather not add it. So, I can't use the web host builder to add everything. Ideally, I could use the existing Program.cs but override a couple of things like the app configuration block and logging setup. |
We experienced the same problem when switching our "controller"-based APIs to the minimal-API approach. While NSwag and SwashBuckle can generate the swagger.json just fine. |
I had had the same problem and had to fix it by manually setting the public class SwaggerHostFactory
{
public static IHost CreateHost()
{
var options = new WebApplicationOptions() { ApplicationName = typeof(SwaggerHostFactory).Assembly.FullName };
var builder = WebApplication.CreateBuilder(options);
...
}
} |
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made. |
Duplicate of #2290. |
Hello,
I am trying to generate the swagger docs on build with
<OpenApiGenerateDocumentsOnBuild>true</OpenApiGenerateDocumentsOnBuild>
but I experience the following error :No method 'BuildWebHost', 'CreateHostBuilder' or 'CreateWebHostBuilder' found in type 'Program' with expected signatures.
Version used : 6.2.3
You can find a minimum repro here :
LuccaSA/minmal-api-samples#2
This repo is a fork of https://github.com/Minimal-APIs/samples made by a microsoftie where they describe how to add open api support (https://minimal-apis.github.io/quickstart/openapi.html)
In the first PR (LuccaSA/minmal-api-samples#1), I added the nuget and the necessary code following the tutorial, and it does indeed work at runtime.
When I inspect the dll, those methods do not exist, so this is "right".
(Note : I experienced the same problem on an internal project also setup as minmal api)
If it's not fixable, would there be a workaround possible ? The doc should probably be updated to mention this case (I could take care of that) ?
Thank you.
The text was updated successfully, but these errors were encountered: