-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Starting from asp.net core 3.0, when making integration tests with WebApplicationFactory, it searches for either
- a method called CreateWebHostBuilder with a return an IWebHostBuilder
- or one called CreateHostBuilder returning an IHostBuilder.
It crashes if it doesn't find any of those two.
In the mustache template for Program.cs, we have a mix of both (IHostBuilder CreateWebHostBuilder).
I suggest changing it to IHostBuilder CreateHostBuilder().
openapi-generator version
v4.3.1
OpenAPI declaration file content or url
the petstore.yaml file would do
Command line used for generation
the default one
Steps to reproduce
- generate the code
- add a integration tests project that uses WebApplicationFactory
- start the test
it crashes with the message : System.InvalidOperationException : No method 'public static IHostBuilder CreateHostBuilder(string[] args)' or 'public static IWebHostBuilder CreateWebHostBuilder(string[] args)' found on 'API.Program'. Alternatively, WebApplicationFactory`1 can be extended and 'CreateHostBuilder' or 'CreateWebHostBuilder' can be overridden to provide your own instance.
Related issues/PRs
none
Suggest a fix
I suggest changing it to IHostBuilder CreateHostBuilder().
Reactions are currently unavailable