skip to Main Content

I use annotations like this from the package Swashbuckle.AspNetCore.Annotations to define responses for swagger:

[SwaggerResponse(200, "OK", typeof(SampleResponseClass))]

Is it possible with this package to define also the headers of the response? And if not what other possibilities would there be?

2

Answers


  1. From what I can tell, there are no pre-existing annotations can be used to describe headers; but you could create your own.

    You can create filters that modify the models produces by Swashbuckle.AspNetCore to enrich the document with additional information. You want to include additional information on an "operation", so you need to implement the IOperationFilter interface.

    I recommend checking out the source code for Swashbuckle.AspNetCore.Annotations for examples of how you can implement the IOperationFilter interface.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search