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

SwaggerSchemaAttribute Title and Description have no effect #2620

Closed
kodeo opened this issue Mar 15, 2023 · 2 comments
Closed

SwaggerSchemaAttribute Title and Description have no effect #2620

kodeo opened this issue Mar 15, 2023 · 2 comments

Comments

@kodeo
Copy link

kodeo commented Mar 15, 2023

I'm using Swashbuckle.AspNetCore 6.5.0 with Swashbuckle.AspNetCore.Annotations 6.5.0 and have added a SwaggerSchemaAttribute to a response class thus:

[SwaggerSchema(Title = "MyTitle", Description = "MyDescription")]
public class MyResponse
{
    public string Id { get; set; }
}

The project docs say I can use this to "to enrich the corresponding Schema metadata that's generated by Swashbuckle", but the generated swagger.json doesn't contain "MyTitle" or "MyDescription" at all, only:

  "MyResponse": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "nullable": true
      }
    },
    "additionalProperties": false
  }
@captainsafia
Copy link
Contributor

@kodeo Have you verified that you have support for annotations enabled in your Swagger generator options ?

builder.Services.AddSwaggerGen(c => c.EnableAnnotations());

@kreditkenny
Copy link

@captainsafia this worked for me! thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants