Description
The purpose of this issue is to align the code produced by the ATC REST API Generator to be as close as possible to what is defined in the OpenAPI specifications document in terms of how Swagger UI is rendered. A good way of testing this is to use the Swagger Petstore v3 example specification, which has become the standard specifications document to test against used when building code generators
Tasks:
- Implement missing support application/octet-stream media types
- Fix Info version property being used incorrectly as the API implementation version
- Missing Swagger UI info metadata
- Missing description (from Info object) in Swagger UI when running the generated API
- Missing termsOfService (from Info object) in Swagger UI when running the generated API
- Missing Contact Information (from Info object) in Swagger UI when running the generated API
- Missing License Information (from Info object) in Swagger UI when running the generated API
- Missing externalDocs (from Info object) in Swagger UI when running the generated API
- Missing servers dropdown (from Info object) in Swagger UI when running the generated API
Swagger UI differences
Here are some screenshots that indicate some pretty obvious differences between the original Swagger Petstore v3 rendered by https://petstore3.swagger.io (or https://editor.swagger.io) and the ATC generated code renders Swagger UI
Implementing missing Info metadata
The OpenAPI Info object is represented by the Microsoft.OpenApi.Models.OpenApiInfo
class and is used when configuring SwaggerGenOptions
Example usage:
public void ConfigureServices(IServiceCollection services)
{
services
.AddSwaggerGen(c =>
{
c.SwaggerDoc("1.0.5", new OpenApiInfo
{
Version = "1.0.5",
Title = "Swagger Petstore - OpenAPI 3.0",
Description = "Swagger Petstore - OpenAPI 3.0 (ASP.NET Core 3.1)",
Contact = new OpenApiContact()
{
Name = "Swagger Codegen Contributors",
Url = new Uri("https://github.com/swagger-api/swagger-codegen"),
Email = "[email protected]"
},
TermsOfService = new Uri("http://swagger.io/terms/")
});
});
}
The correct way of doing this is by implementing IConfigureOptions<SwaggerGenOptions>
so that developers can have multiple implementations of IConfigureOptions<SwaggerGenOptions>
whereas using the AddSwaggerGen
extension method will prevent IConfigureOptions<SwaggerGenOptions>
implementations from being called