Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS OpenAPI does not generate a valid schema for nullable complex properties #59976

Open
1 task done
luisabreu opened this issue Jan 21, 2025 · 0 comments
Open
1 task done
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi

Comments

@luisabreu
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The new OpenAPI support for ASP.NET Core projects generates semantic errors for some types, specifically for $ref entries. The sample below reproduces the issue: one of the properties gets the following ref: "$ref" "#/components/schemas/#/properties/locaisRemover/items/properties/locais" which produces invalid description.

Expected Behavior

No response

Steps To Reproduce

Here's a sample that reproduces the issue by using and :

using Microsoft.AspNetCore.Http.HttpResults;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi( );
var app = builder.Build( );

// Configure the HTTP request pipeline.
if( app.Environment.IsDevelopment( ) ) {
    app.MapOpenApi( );
}
app.UseHttpsRedirection( );

app.MapPut("/test",
           (MsgMovimentacaoLocaisTrabalho msg) => Results.Ok( ))
   .WithName("GetWeatherForecast");

app.Run( );


public class MsgMovimentacaoLocaisTrabalho {    
    public IList<InfoGeral>? LocaisRemover { get; set; }
    public InfoGeral? LocaisAssociar { get; set; }
}

public class InfoGeral {    
    public Guid GuidDirecao { get; set; }
    public IEnumerable<int> Locais { get; set; } = Enumerable.Empty<int>();
}

Exceptions (if any)

No response

.NET Version

9.0.101

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Jan 21, 2025
@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants