Skip to content

Code generation based on Swagger Petstore v3 OpenAPI specifications #63

Open
@christianhelle

Description

@christianhelle

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:

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

swagger-petstore3

atc-swagger-petstore3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions