ASP.NET Core Web API Interview Question #90
What is Swagger in relation to OpenAPI?
Routing, Versioning, OpenAPI/Swagger & API Documentation Mid-Level Intermediate
Quick Interview Answer
OpenAPI is the specification, while Swagger commonly refers to a family of tools built around API descriptions, such as interactive Swagger UI. In ASP.NET Core, developers often generate an OpenAPI document and expose an interactive UI for development or documentation.
Detailed Explanation
OpenAPI is the specification, while Swagger commonly refers to a family of tools built around API descriptions, such as interactive Swagger UI. In ASP.NET Core, developers often generate an OpenAPI document and expose an interactive UI for development or documentation.
The terms are frequently used together, but distinguishing the specification from the tooling is useful in interviews and architecture discussions.
Code Example
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
app.UseSwagger();
app.UseSwaggerUI();