dotnet / dotnet/aspnetcore

OpenApi custom polymorphic type names

Open
#58,332 7 comments 14 reactions 0 assignees View on GitHub
area-minimal area-mvc feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

We're looking into migrating from Swashbuckle to Microsoft.AspNetCore.OpenApi. There are many benefits but polymorphic type naming is a larger issue for us as it makes generated type names hard to read. In our case we use the base type name as a suffix, e.g.

```csharp
abstract class JobTemplate { ... }
class FooJobTemplate : JobTemplate { .. }
```

Generates a type called: `JobTemplateFooJobTemplate`.

### Describe the solution you'd like

Any way to customize the generated schema name. In Swashbuckle we could configure a delegate that took a Type and returned a String.

### Additional context

#57982 and #58213 also mention this particular issue.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing related issues #57982 and #58213 and the existing Swashbuckle configuration described in the report. The work is complete when Microsoft.AspNetCore.OpenApi provides a way to customize generated schema names, including polymorphic names such as FooJobTemplate without the JobTemplate prefix.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.