Skip to content

[OpenAPI] Invalid schema references generated #63090

@martincostello

Description

@martincostello

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

To validate the changes made in #63052 I put the OpenAPI schema into editor.swagger.io to see if the schema for JSON Patch had any validation errors (it does not).

However, amongst a few schema errors that are found in the document that aren't just artifacts of testing, I found two that appear to be actual issues:

  1. Semantic error at components.schemas.Category.properties.tags.$ref - $refs must reference a valid ___location in the document from
  2. Semantic error at components.schemas.Item.properties.name.$ref - $refs must reference a valid ___location in the document from

These correlate to these parts of the code:

  1. public IEnumerable<Tag> Tags { get; set; } = [];
  2. public string[] Name { get; set; } = null!;

Both of these properties are arrays and appear to generate a circular reference to themselves via another object.

  1. Points to the tags property of the parent property of itself, but that's also a Category, so it's just a circular reference to itself.
  2. Points to the name property of the item1 property of Root, but that's also an Item, so again creates a circular reference to itself.

In both cases it looks like the schema properties should be an array of items which reference Tag or Item respectively.

Expected Behavior

The schemas do not generate validation errors.

Steps To Reproduce

Enter the contents of OpenApiDocumentLocalizationTests.VerifyOpenApiDocumentIsInvariant.verified.txt into editor.swagger.io.

Exceptions (if any)

No response

.NET Version

10.0.100-preview.7.25322.101

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions