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

v2: Handle relative references in OpenApiSchemaReference type #2062

Open
captainsafia opened this issue Jan 15, 2025 · 1 comment
Open

v2: Handle relative references in OpenApiSchemaReference type #2062

captainsafia opened this issue Jan 15, 2025 · 1 comment
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days
Milestone

Comments

@captainsafia
Copy link
Member

captainsafia commented Jan 15, 2025

The OpenApiSchemaReference type included in this package provides support for resolving schema references to the top-level components.schemas object. The object doesn't play nice if the reference is a relative reference to a property in a recursive schema.

The serializer seems to detect these relative references correctly and serialize the correct references. It would be great if these resolutions also worked in the object model, particularly for users taking advantage of consuming APIs' in ASP.NET Core like OpenAPI schema transformers.

For example, given the following type hierarchy:

public class A
{
	public B B { get; }
}

public class B
{
	public C C { get; }
}

public class C
{
	public B B { get; set; } 
}

And the following schema:

{
  "type": [
    "object",
    "null"
  ],
  "properties": {
    "b": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "c": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "b": {
              "$ref": "#/properties/b"
            }
          }
        }
      }
    }
  }
}

#/properties/b should map to the properties.b schema when interacting with the OpenApiSchemaReference object for the schema.

@baywet
Copy link
Member

baywet commented Jan 31, 2025

While working on the proxy design pattern fix, I came to the same conclusion!
#2111 (comment)

The good news is that with the work I've done, it should now be a single place fix + providing a recursion method to resolve the actual schema when necessary.

@RachitMalik12 RachitMalik12 added this to the v2-Preview6 milestone Jan 31, 2025
@RachitMalik12 RachitMalik12 added the priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days label Jan 31, 2025
@baywet baywet modified the milestones: v2-Preview6, v2 - Preview7 Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days
Projects
None yet
Development

No branches or pull requests

3 participants