attatch swagger

main
Peace 1 year ago
parent 004bff4336
commit 36b312e281
  1. 6
      AspNetCoreLearnOfficial.sln
  2. 4
      MinimumWebAPI/PizzaStore.csproj
  3. 16
      MinimumWebAPI/Program.cs

@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApi", "WebApi\WebApi.csproj", "{9FAB855B-340B-4F20-9C96-091F36B18706}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzaStore", "MinimumWebAPI\PizzaStore.csproj", "{01E3A866-5135-403E-9059-42EAC85586BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{9FAB855B-340B-4F20-9C96-091F36B18706}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FAB855B-340B-4F20-9C96-091F36B18706}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FAB855B-340B-4F20-9C96-091F36B18706}.Release|Any CPU.Build.0 = Release|Any CPU
{01E3A866-5135-403E-9059-42EAC85586BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01E3A866-5135-403E-9059-42EAC85586BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01E3A866-5135-403E-9059-42EAC85586BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01E3A866-5135-403E-9059-42EAC85586BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -6,4 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>

@ -1,8 +1,24 @@
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "PizzaStore API", Description = "Making the Pizzas you love", Version = "v1" });
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
});
}
app.MapGet("/", () => "Hello World!");
app.Run();

Loading…
Cancel
Save