Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSwag - how do I add comments?

I use NSwag in an ASP.Net WebAPI project to generate a swagger interface - which works great.

Say I have a method I want to add some explanations to - how can I do that?

By comment I mean something that when a user of the API is looking at the documentation will see.

I have googled, binged and ... ducked? - but was unable to find anything about it. Maybe I am using wrong terms.

like image 956
Kjensen Avatar asked Sep 03 '25 07:09

Kjensen


1 Answers

To use annotation-based documentation with NSwag you must install the package NSwag.Annotations.

Then you can use annotations like that:

[SwaggerResponse(HttpStatusCode.OK, typeof(MyResponseType), Description = "Returns the object containing data ...")]

There are many annotations to choose from; each are presented differently in the web UI.

like image 200
alsami Avatar answered Sep 04 '25 23:09

alsami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!