dotnet / dotnet/aspnetcore

Microsoft.Extensions.ApiDescription.Server does not allow explicit file name with dots

Open
#65,802 1 comment 0 reactions 0 assignees View on GitHub
area-commandlinetools bug feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

**OpenAPI** document generation uses the project file name for the base for the document file name.

The project file name `MSBuildProjectName` **MSBuild** property is used to generate the `ProjectName`. `RootNamespace`, and `AssemblyName` properties, if not set, but they can be set to anything the user wants.

As an example, I can have this on my `Directory.Build.props`:

```XML


MyCompany.MyProduct
$(MSBuildProjectName.Replace(" ", "_"))
$(BaseArtifactName).$(RootNamespace)
$(RootNamespace)
$(MSBuildProjectName)
$(BaseArtifactName).$(AssemblyName)



$(MSBuildThisFileDirectory)

```

This will cause `MSBuildProjectName` to be used for the file name.

I don't think `MSBuildProjectName` should be used for anything other than referring to the project file. The project name should be taken from `ProjectName`.

If I want to fix that, I need to set it in the `OpenApiGenerateDocumentsOptions` MSBuild property (see [this](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi#modify-the-output-file-name)):

```XML

--file-name $(ProjectName)

```

Except that these names usually have dots in it and `--file-name` does not accept dots.

But if you let it use the `MSBuildProjectName`, it will use dots.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.