liveBook · Manning

Swagger.json

As explained in Building Web APIs with ASP.NET Core

swagger.json is a generated JSON document that describes an HTTP API according to the OpenAPI specification.

swagger.json is a generated JSON document that describes an HTTP API using the OpenAPI specification. Swashbuckle creates it from the ASP.NET Core application’s endpoints, request types, and response types. section 3.2.2 section 11.2.1

ASP.NET Core exposes the document at /swagger/v1/swagger.json through UseSwagger. SwaggerUI reads that JSON at /swagger and turns it into an interactive API client for browsing and testing endpoints. section 3.2.2 section 11.2.1

// ...
 
builder.Services.AddSwaggerGen();    #1
 
// ...
 
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();                #2
    app.UseSwaggerUI();              #3
}

Register the generator, then enable the JSON middleware and user interface in the development environment. section 3.2.2

Grouping endpoints

Swashbuckle adds controller names to the document’s tags property, so controller-based endpoints appear in related SwaggerUI groups. Minimal API methods lack controllers and therefore need explicit tags, such as Tags = new[] { "Auth" } in SwaggerOperation. section 11.2.7

The default document uses OpenAPI 3.0 and API version 1.0. Swashbuckle options can change the specification version, add documents, customize the SwaggerUI page, and postmodify generated descriptions. section 3.2.2 section 11.5

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains generation, serving, defaults, and tagging, while deferring detailed Swashbuckle configuration.
Examples
Uses development middleware, localhost endpoints, controller tags, and an explicit Auth tag for Minimal API operations.
What it assumes
Assumes an ASP.NET Core web API created with OpenAPI support while introducing the generated document and its delivery endpoints.
What you can do after
Operate SwaggerUI to browse and test endpoints, or configure Swashbuckle to customize the generated API documentation.
How it connects
Connects OpenAPI, Swashbuckle, SwaggerUI, ASP.NET Core, controllers, Minimal APIs, and SwaggerOperation attributes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.