dotnet / dotnet/aspnetcore

Oput examples under the examples key when generating openapi documents

Open
#65,181 5 comments 0 reactions 0 assignees View on GitHub
area-minimal feature-openapi help wanted
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

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.

I am trying to generate openapi documents using the new XML comment feature in .net10
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/openapi-comments?view=aspnetcore-10.0

My issue it that the example is added under an "example" field under the "schema" key. And form what I can read in the openapi spec that field is deprecated.

This becomes an issue for me when I try to import my openapi spec into the API-gateway solution we use at my organization.

This is what my code generates today with Microsoft.AspNetCore.OpenApi version "10.0.2" :
[current.json](https://github.com/user-attachments/files/24791111/current.json)

### Describe the solution you'd like

I would like it to generate something like this:
[target.json](https://github.com/user-attachments/files/24791112/target.json)

### Additional context

https://spec.openapis.org/oas/v3.1.1.html#working-with-examples
https://spec.openapis.org/oas/v3.1.1.html#schema-object

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.