Home > Back-end >  Swagger/OpenAPI static file not appearing
Swagger/OpenAPI static file not appearing

Time:06-18

I'm trying make the dotnet 6 Weather API example generate the static swagger.json or swagger.yaml.

I'm pretty sure i've followed the steps from Microsoft docs but no static files are being generated, i'm expected them to appear on build.

Microsoft docs url:
enter image description here

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.3.1" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.1" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.3.1" />
  </ItemGroup>
  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="dotnet tool restore" />
    <Exec Command="dotnet new tool-manifest --force" />
    <Exec Command="dotnet tool install --local Swashbuckle.AspNetCore.Cli"/>
    <Exec Command="dotnet swagger tofile --output swagger.json $(OutputPath)\$(AssemblyName).dll v1 " />
</Target>
</Project>
  • Related