- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.3k
Closed
Labels
staleStale issues or pull requestsStale issues or pull requests
Description
Minimal API
I'm using Swashbuckle.AspNetCore 6.5.0 with Swashbuckle.AspNetCore.Annotations 6.5.0 and have added a SwaggerRequestBodyAttribute to a response class thus:
app.MapPost("/todos", ([FromBody, SwaggerRequestBody("Todo object to be created", Required = true)] Todo todo) =>
    {
        todos.Add(todo with { Id = Guid.NewGuid() });
        return TypedResults.Ok(todo);
    })
    .WithOpenApi(operation => new(operation)
    {
        Summary = "Create a todo",
        OperationId = "createTodo",
        Tags = new List<OpenApiTag> { new() { Name = "Todos" } },
        //Parameters = new List<OpenApiParameter>
        //{
        //    new OpenApiParameter{ Description ="Todo object to be created" }
        //}
    });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:
"post": {
    "tags": [
      "Todos"
    ],
    "summary": "Create a todo",
    "operationId": "createTodo",
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Todo"
          }
        }
      },
      "required": true
    },
    "responses": {
      "200": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Todo"
            }
          }
        }
      }
    }
  }My configurations
builder.Services.AddSwaggerGen(options =>
{
    options.SwaggerDoc("v1", new OpenApiInfo { Title = "ChatGPT Plugin", Version = "v1" });
    options.DocInclusionPredicate((docName, apiDesc) => true);
    options.EnableAnnotations();
});Metadata
Metadata
Assignees
Labels
staleStale issues or pull requestsStale issues or pull requests