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

SwaggerSchema attribute description is ignored on complex-typed members #2141

Closed
tyler-boyd opened this issue Jun 16, 2021 · 3 comments
Closed

Comments

@tyler-boyd
Copy link
Contributor

Hi,

I'm using v6.0.1 of SwashBuckle. Here's a minimal example of what I'm talking about:

public class Foo {
  [SwaggerSchema("This is a special kind of bar")]
  public Bar Bar { get; set; }

  [SwaggerSchema("Descriptions on simple types do work")]
  public int SomeNumber { get; set; }
}

public class Bar {
   // omitted 
}

The generated swagger doesn't contain the "This is a special kind of bar" description on the Foo's Bar field. Am I doing something wrong or is this a bug in the library?

@officeSpacePirate
Copy link

officeSpacePirate commented Jul 8, 2021

I'm experiencing the same thing. This applies to using either the SwaggerSchemaAttribute or the summary code comment.

@privjimmie
Copy link

I'm also experience the same issue with the SwaggerSchema attribute

Examples on my model

[SwaggerSchema(ReadOnly = true, Description = "forward test desc")]
public string forward_to_email { get; set; }

[SwaggerSchema(ReadOnly = true, Description = "type test desc")]
public _DTO_enums.group_type type { get; set; }

and produced json

image

I also tried setting it as a SchemaFilter, like this (not exactly, but you get the point), and still not affecting the output

public class ReadOnlyFilter : ISchemaFilter
    {
        public void Apply(OpenApiSchema model, SchemaFilterContext context)
        {
            ...
            foreach (var prop in model.Properties)
            {
                prop.Value.ReadOnly = true;
            }
            ...
        } 
    }

@mikeMoreno
Copy link

Support for sibling keywords alongside a $ref was added in OpenAPI 3.1.

Swashbuckle currently only supports up to OpenAPI 3.0.


Relevant links:

The issue in OpenAPI is mentioned: OAI/OpenAPI-Specification#1514

Swashbuckle's plans to support OpenAPI 3.1: #2349

A comment on the OpenAPI.NET project that mentions support for this explicitly: microsoft/OpenAPI.NET#795 (comment)

@martincostello martincostello closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants