Skip to content

OpenAPI: Description Attribute is not applied to schema references #63175

@desjoerd

Description

@desjoerd

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the [Description] attribute it would apply the description to the actual schema for each property referencing that schema.

in the example below

    [Description("Class: DescribedReferencesDto")]
    public class DescribedReferencesDto
    {
        [Description("Property: DescribedReferencesDto.Child1")]
        public DescribedChildDto Child1 { get; set; }

        [Description("Property: DescribedReferencesDto.Child2")]
        public DescribedChildDto Child2 { get; set; }

        public DescribedChildDto ChildNoDescription { get; set; }
    }

    [Description("Class: DescribedChildDto")]
    public class DescribedChildDto
    {
        [Description("Property: DescribedChildDto.ChildValue")]
        public string ChildValue { get; set; }
    }

The description of DescribedChildDto would become Property: DescribedReferencesDto.Child2.

Also [Description] attributes are only applied from properties.

Expected Behavior

[Description] attributes should apply to the schema reference for referenced schemas.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

.NET 10 preview 7

Anything else?

Related to #62213 and #61965

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions