Skip to content

Microsoft.Extensions.ApiDescription.Server : After build, OpenAPI specification file isn't present in the build result #59334

Open
@vernou

Description

@vernou

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I try to follow the documentation Generate OpenAPI documents at build-time, but the OpenAPI specification file isn't present in the build result.

I reproduce on Windows 10 and Windows 11 (I haven't tested it elsewhere).

Expected Behavior

The OpenAPI specification file is in the build result.

Steps To Reproduce

So the script :

dotnet new webapi --name MyApi --no-https --use-program-main --use-controllers
cd MyApi
dotnet add package Microsoft.Extensions.ApiDescription.Server
dotnet build

Then if we display the bin :

> dir bin\Debug\net9.0

 Volume in drive C has no label.
 Volume Serial Number is 60F0-FEC7

 Directory of C:\t\dotnte-poc\MyApi\bin\Debug\net9.0

05/12/2024  15:50    <DIR>          .
05/12/2024  15:50    <DIR>          ..
05/12/2024  15:50               127 appsettings.Development.json
05/12/2024  15:50               151 appsettings.json
29/10/2024  14:30           192 800 Microsoft.AspNetCore.OpenApi.dll
06/08/2024  10:15           239 024 Microsoft.OpenApi.dll
05/12/2024  15:50             2 235 MyApi.deps.json
05/12/2024  15:50             8 704 MyApi.dll
05/12/2024  15:50           145 408 MyApi.exe
05/12/2024  15:50            21 348 MyApi.pdb
05/12/2024  15:50               416 MyApi.runtimeconfig.json
05/12/2024  15:50                68 MyApi.staticwebassets.endpoints.json
              10 File(s)        610 281 bytes
               2 Dir(s)  98 535 710 720 bytes free

The file MyApi.json is missing.


But the file is correctly generated and present in obj :

>dir obj

 Volume in drive C has no label.
 Volume Serial Number is 60F0-FEC7

 Directory of C:\t\dotnte-poc\MyApi\obj

05/12/2024  15:50    <DIR>         .
05/12/2024  15:50    <DIR>         ..
05/12/2024  15:50    <DIR>         Debug
05/12/2024  15:50             2 982  MyApi.csproj.nuget.dgspec.json
05/12/2024  15:50             2 165  MyApi.csproj.nuget.g.props
05/12/2024  15:50               551   MyApi.csproj.nuget.g.targets
05/12/2024  15:50             1 730  MyApi.json                                 <<<<< Here
05/12/2024  15:50                38    MyApi.OpenApiFiles.cache
05/12/2024  15:50            20 520 project.assets.json
05/12/2024  15:50               581   project.nuget.cache
               7 File(s)         28 567 bytes
               3 Dir(s)  98 537 242 624 bytes free

Exceptions (if any)

No response

.NET Version

9.0.101

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions