The idea behind all the changes here is to fix the incorrect usage of the Info Version according to the specification documentation
I also replaced hard coded route paths that start with /api/[version]/xxx to use what is specified in the OpenAPI spec Servers property if that is defined, otherwise default to /api/v1/xxx since that is what is being attempted in the BaseProjectOptions class
The documentation for the Server URL states:
A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in {brackets}.
public class PetApiController : ControllerBase
{
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks>Add a new pet to the store</remarks>
/// <param name="body">Create a new pet in the store</param>
/// <response code="200">Successful operation</response>
/// <response code="405">Invalid input</response>
[HttpPost]
[Route("/api/v3/pet")]
[ValidateModelState]
[SwaggerOperation("AddPet")]
[SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "Successful operation")]
public virtual IActionResult AddPet([FromBody]Pet body)
{
throw new NotImplementedException();
}
}
This fixes issue #69
The idea behind all the changes here is to fix the incorrect usage of the Info Version according to the specification documentation
I also replaced hard coded route paths that start with
/api/[version]/xxx
to use what is specified in the OpenAPI spec Servers property if that is defined, otherwise default to/api/v1/xxx
since that is what is being attempted in theBaseProjectOptions
classThe documentation for the Server URL states:
The Swagger Online Editor using Swagger Petstore v3 spec generates a MVC API Controller like this:
Here is a screenshot of Swagger UI when running generated code using Swagger Petstore v3 OpenAPI specifications document: