Skip to content

[10.0-preview.1] ASP.NET OpenApi document references broken #60686

@erwinkramer

Description

@erwinkramer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm attempting to upgrade a project to .NET 10, but I'm stumbling on OpenAPI document references not being recognized.

Please see the Specs.Generated/openapi_v1.json file @ https://github.com/erwinkramer/bank-api/pull/6/files#diff-81441684a5afd97bb8736d8939ce636edf0936cf16f15184fe4e73278066d9fc - That's the diff between .NET 9 and .NET 10.

It seems that using OpenApiSchemaReference for instance, as used here https://github.com/erwinkramer/bank-api/pull/6/files#diff-7cef44f296701d069cf15399e7712e91f9f7b3de0cf09f98295d608122abf97e does help with getting the correct references. However, inside of https://github.com/erwinkramer/bank-api/blob/feature/dotnet10/BankApi.Core/Defaults/Transformer.Operation.cs - in order to do the same - i have to make use of OpenApiResponseReference for the references at the AddStandardResponses method, and somehow get the OpenApiDocument object inside the IOpenApiOperationTransformer, because that is what OpenApiResponseReference and similar reference methods require. This all seems a bit impracticable, unless i'm going to convert the whole file to an IOpenApiDocumentTransformer, but then i lose the OpenApiOperationTransformerContext.

Am i totally on the wrong path, or is this still just work in progress and not expected to work at this time? Let me know.

Expected Behavior

Should return no significant difference in OpenAPI spec outputs generated by .NET by upgrading to .NET 10

Steps To Reproduce

Build .NET 9 version on: https://github.com/erwinkramer/bank-api/tree/main
Build .NET 10 version on: https://github.com/erwinkramer/bank-api/tree/feature/dotnet10

See the difference on the generated OpenAPI files.

Exceptions (if any)

I see some warnings like:

CSC : warning AD0001: Analyzer 'Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'. [c:\Users\erwin\bank-api\BankApi.Service.Stable\BankApi.Service.Stable.csproj]

... but it's hard to pinpoint and validate if they are related.

.NET Version

10.0.100-preview.1.25120.13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions