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

Incorrect type reference #1995

Open
fvaillancourt opened this issue Dec 18, 2024 · 0 comments
Open

Incorrect type reference #1995

fvaillancourt opened this issue Dec 18, 2024 · 0 comments

Comments

@fvaillancourt
Copy link

fvaillancourt commented Dec 18, 2024

Describe the bug
Incorrect type reference returned for certain class (record) structure.

Steps To Reproduce

  1. Create a new ASP.net project with top level statements (.Net 9)
  2. Add Microsoft.AspNetCore.OpenApi 9.0
  3. Replace the code with:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();

var app = builder.Build();
app.MapOpenApi();
app.MapPost("/", (TypeA _) => "Hello World");
app.Run();

public record TypeC(string Id);
public record TypeB(TypeC C);
public record TypeD(TypeB B);
public record TypeA(TypeB B, TypeD D);

Observed behavior
Here is a portion of the file with the offending content. Look at the $ref type.

      "TypeB2": {
        "required": [
          "c"
        ],
        "type": "object",
        "properties": {
          "c": {
            "$ref": "#/components/schemas/#/properties/b/properties/c"
          }
        }
      }

Expected behavior
Not sure yet why we get a TypeB (not shown) and TypeB2, maybe cause here by the bug as it has different type (ref). I would expect the $ref value to be "#/components/schemas/TypeC" and not "#/components/schemas/#/properties/b/properties/c". I am not an OpenApi expert but it does not look like a valid type reference and it fails to parse in all tools I tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant