Skip to content

Fix self-referential schema handling for collection-based types #60339

Closed
@captainsafia

Description

@captainsafia

Based on feedback from #58968 (comment) and #58968 (comment).

We need to resolve the bug for schema comparisons around the following type hierarchy:

// List<LocationContainer>
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "location": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "address": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "relatedLocation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "address": {
                    "$ref": "#/items/properties/location/properties/address",
                    "x-schema-id": "AddressDto",
                    "nullable": true
                  }
                },
                "x-schema-id": "LocationDto",
                "nullable": true
              }
            },
            "x-schema-id": "AddressDto",
            "nullable": true
          }
        },
        "x-schema-id": "LocationDto",
        "nullable": true
      }
    },
    "x-schema-id": "LocationContainer"
  }
}

// LocationContainer[]
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "location": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "address": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "relatedLocation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "address": {
                    "$ref": "#/items/properties/location/properties/address",
                    "x-schema-id": "AddressDto",
                    "nullable": true
                  }
                },
                "x-schema-id": "LocationDto",
                "nullable": true
              }
            },
            "x-schema-id": "AddressDto",
            "nullable": true
          }
        },
        "x-schema-id": "LocationDto",
        "nullable": true
      }
    },
    "x-schema-id": "LocationContainer"
  }
}

// Dictionary<string, LocationContainer>
{
  "type": "object",
  "additionalProperties": {
    "type": "object",
    "properties": {
      "location": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "address": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "relatedLocation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "address": {
                    "$ref": "#/additionalProperties/properties/location/properties/address",
                    "x-schema-id": "AddressDto",
                    "nullable": true
                  }
                },
                "x-schema-id": "LocationDto",
                "nullable": true
              }
            },
            "x-schema-id": "AddressDto",
            "nullable": true
          }
        },
        "x-schema-id": "LocationDto",
        "nullable": true
      }
    },
    "x-schema-id": "LocationContainer"
  }
}

// ListContainer
{
  "type": "object",
  "properties": {
    "location": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "address": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "relatedLocation": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "address": {
                  "$ref": "#/properties/location/properties/address",
                  "x-schema-id": "AddressDto",
                  "nullable": true
                }
              },
              "x-schema-id": "LocationDto",
              "nullable": true
            }
          },
          "x-schema-id": "AddressDto",
          "nullable": true
        }
      },
      "x-schema-id": "LocationDto",
      "nullable": true
    }
  },
  "x-schema-id": "LocationContainer"
}

Metadata

Metadata

Assignees

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions