Skip to content
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

Code generation based on Swagger Petstore v3 OpenAPI specifications #63

Open
5 of 9 tasks
christianhelle opened this issue Jan 27, 2021 · 1 comment
Open
5 of 9 tasks
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@christianhelle
Copy link
Member

christianhelle commented Jan 27, 2021

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

@MrAndersPedersen
Copy link

Hi @christianhelle
Do you still need help?
Please reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants