In the previous post, I introduced Swagger and showed how to set up your project for Swagger. In this post I will show how to add Swagger comments to annotate your program.
In earlier posts we looked at the database of cars and the Get method that retrieves the entire list. That can be quite a lot of data going over the wire. What we want instead is to send pages. I’ll show that briefly and then we’ll annotate that code.
In the CarController we’ll have a Get method that takes three parameters: showDeleted, pageNumber and pageSize. The first we’ve seen before, it determines whether the list returned to the caller will include our deleted records. The second, pageNumber, will designate which page of data we want to return (zero based). The third parameter, pageSize, will designate how many records to return per page.
Thus, if we were to write
Get(false,3,4)
we would expect to get back records 17, 18, 19 and 20, because page 0 would have records 1-4, page 1 would have 5-8, etc.
Here is the compete endpoint that will directly call our repository (we won’t bother with a service for this example).
public async Task<IEnumerable<Car>> Get([FromRoute] bool showDeleted, int pageNumber, int pageSize )
{
return await _carRepository.Get(showDeleted, pageNumber, pageSize);
}
When the repository is called, the parameters are passed in, and it does its magic. For now, however, we are only concerned with documenting this method. We do that with XML comments, designated by three forward slash marks (///).
First, we will document the purpose of the endpoint; that is, what it does. We do that in the summary
/// <summary>
/// Get all the cars in the Database
/// </summary>
Next, we want to document the parameters
/// <param name="returnDeletedRecords">If true, the method will return all the records,
/// including the ones that have been deleted</param>
/// <param name="pageOffset">which page to display</param>
/// <param name="pageSize">how many records to display per page</param>
Finally, I’m going to document the possible response codes. Note, these are, by no means, all that you can document, but they’ll give us a good idea of how it is done
/// <response code="200">Cars returned</response>
/// <response code="404">Specified Car not found</response>
/// <response code="500">An Internal Server Error prevented the request from being executed.</response>
When an error is encountered and we return one of these codes, the text we’ve specified goes along for the ride, which is enormously helpful to the calling client.
At the top of the swagger page is our summary

At each parameter is our designated text

Finally, each of the error codes is documented

It is a best practice to document all of the endpoints. Many developers go further, and document all of the methods in both the service and the repository; that is a decision to be made by the team. Since the endpoint is the only thing visible to the client, it has the greatest claim on your time and effort. Remember, “comments rust,” and that is as true for Swagger comments as any other.






































เนื้อหานี้ ให้ข้อมูลดี ค่ะ
ผม ได้อ่านบทความที่เกี่ยวข้องกับ เนื้อหาในแนวเดียวกัน
ซึ่งอยู่ที่ Sylvester
น่าจะถูกใจใครหลายคน
เพราะอธิบายไว้ละเอียด
ขอบคุณที่แชร์ คอนเทนต์ดีๆ นี้
และหวังว่าจะมีข้อมูลใหม่ๆ มาแบ่งปันอีก
Excellent post. Keep writing such kind of information on your blog. Im really impressed by your site.
Hi there, You’ve done a fantastic job. I will definitely digg it and in my opinion recommend to my friends. I am confident they will be benefited from this site.
Viagra sans ordonnance livraison 24h: Prix du Viagra 100mg en France – Viagra gГ©nГ©rique sans ordonnance en pharmacie
References:
Casino zandvoort https://quickdatescript.com/@nidiaday363515@nidiaday363515
References:
Sky dancer casino https://https://goondepot.com/@christinakraeg?page=about/@christinakraeg?page=about
Superb post however I was wondering if you could write a
litte more on this subject? I’d be very grateful if you could elaborate a little bit further.
Thanks! เบทฟิก22
The way this post presents its ideas makes the discussion feel well-rounded, interesting, and relatable for a wide range of readers online.
Coolzino
Aw, this was an extremely nice post. Taking the time and actual effort to make a good article… but what can I say… I put things off a whole lot and never manage to get nearly anything done.
mostbet bezpečnostní kontrola mostbet bezpečnostní kontrola
Москвичи отзовитесь Решил снести стену между комнатами А тут оказывается бумажек этих Нервов потратил — пипец Короче, единственное что реально работает — услуги по согласованию перепланировки без проблем Сроки реальные — не затягивают В общем, сохраняйте себе — согласование перепланировки москва согласование перепланировки москва Не тяните Перешлите тому кто затеял ремонт
Svenska Pharma: Svenska Pharma – Svenska Pharma
Greate article. Keep writing such kind of info on your blog. Im really impressed by it.
Слушайте кто делал проект Замучился я уже с этим согласованием Оказывается без бумажки ты никто Нервов просто нет Короче, единственные кто делает быстро — проект перепланировки квартиры для согласования в МЖИ И техзаключение сделали В общем, там и примеры и цены — перепланировка квартиры проектные организации https://proekt-pereplanirovki-kvartiry-hmf.ru Потом себе дороже Перешлите тому кто ремонт затеял
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.
Currently it appears like WordPress is the preferred blogging platform out there right now. (from what I’ve read) Is that what you are using on your blog?
mexican pharmacies online drugs: mexican drug stores – progreso, mexico pharmacy online
Mobil bahis için doğru apk dosyasını bulmak epey zordu valla. Herkes farklı bir şey tavsiye ediyordu kime inanacağımı şaşırdım. Güncel bilgileri kontrol edip süreci hatasız başlattım. En sonunda sağlam bir adrese ulaştım ve size de tüm detayları aktarmak istedim, güncel bilgilere buradan bakabilirsiniz: 1xbet download android 1xbet download android. Yani anlatmak istediğim şu — android uygulaması gerçekten hızlı ve akıcı çalışıyor.
Hiçbir güvenlik sorunu yaşamadım yükleme esnasında. Birçok apk denedim ama en başarılısı bu çıktı — kesinlikle pişman olmazsınız deneyin derim. Umarım siz de memnun kalırsınız…
https://mexicoexpharm.click/# order from mexico
Слушайте кто ремонт затеял Цены космос а качество мыло То ЛДСП 16 мм а не 18 Короче, нашел нормальных производителей — заказать кухню по индивидуальным размерам Цены ниже рыночных на треть В общем, жмите чтобы не потерять — купить кухню купить кухню Проверяйте производителя по этому списку Сам полгода выбирал теперь знаю
Greate post. Keep writing such kind of info on your blog. Im really impressed by your site.
Can I simply say what a relief to discover someone who actually knows what they are talking about on the net. You certainly understand how to bring an issue to light and make it important. More people ought to look at this and understand this side of your story. I can’t believe you’re not more popular since you certainly possess the gift.
Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say excellent blog!
Hey there, You have performed a great job. I’ll definitely digg it and in my view recommend to my friends. I’m sure they’ll be benefited from this web site.
Aw, this was an extremely nice post. Spending some time and actual effort to produce a really good article… but what can I say… I procrastinate a whole lot and don’t seem to get anything done.
May I simply say what a relief to find somebody who actually understands what they are discussing on the web. You actually understand how to bring an issue to light and make it important. A lot more people should check this out and understand this side of the story. I can’t believe you aren’t more popular given that you certainly have the gift.
Nicely put, Appreciate it.
Aw, this was an exceptionally good post. Taking a few minutes and actual effort to produce a good article… but what can I say… I put things off a lot and never seem to get anything done.
Great info. Regards!
You’ve made your point quite well..
At this time it sounds like Expression Engine is the best blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog?
At this time it sounds like Expression Engine is the preferred blogging platform out there right now. (from what I’ve read) Is that what you’re using on your blog?
Всем привет из Питера Замучился я уже кухню выбирать То фасады кривые с зазорами Короче, нашел наконец нормальное производство — кухни СПб напрямую от производителя Кромка на немецком оборудовании В общем, жмите чтобы не потерять контакт — кухня на заказ кухня на заказ Проверяйте производителя по этому списку Сам столько нервов потратил теперь делюсь опытом
online mexican pharmacy: mexican pharmacy – online mexican pharmacy
Народ всем привет Фурнитуру ставят дешманскую То фасады кривые Короче, нашел наконец нормальное производство — кухни на заказ в спб с установкой Замерщик приехал на следующий день В общем, смотрите сами по ссылке — кухни на заказ санкт петербург от производителя https://kuhni-spb-uio.ru Проверяйте производителя по этому списку Перешлите тому кто тоже мучается
Aw, this was an exceptionally nice post. Spending some time and actual effort to generate a good article… but what can I say… I put things off a whole lot and don’t seem to get nearly anything done.
At this time it looks like WordPress is the top blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog?
คอนเทนต์นี้ น่าสนใจดี ค่ะ
ดิฉัน ได้อ่านบทความที่เกี่ยวข้องกับ เรื่องที่เกี่ยวข้อง
ซึ่งอยู่ที่ เล่น BIGBONUS168
บนมือถือ
น่าจะถูกใจใครหลายคน
มีตัวอย่างประกอบชัดเจน
ขอบคุณที่แชร์ คอนเทนต์ดีๆ นี้
และหวังว่าจะได้เห็นโพสต์แนวนี้อีก
Currently it appears like Drupal is the top blogging platform out there right now. (from what I’ve read) Is that what you are using on your blog?
Aw, this was an exceptionally good post. Taking a few minutes and actual effort to make a very good article… but what can I say… I hesitate a lot and don’t manage to get anything done.
Узнать больше kraken сайт
Aw, this was a very nice post. Taking a few minutes and actual effort to generate a superb article… but what can I say… I procrastinate a lot and don’t manage to get nearly anything done.
Hello friends!
I came across a 179 useful site that I think you should visit.
This platform is packed with a lot of useful information that you might find helpful.
It has everything you could possibly need, so be sure to give it a visit!
https://thinkcomputers.org/top-5-steampunk-themed-video-games-for-sci-fi-buffs/
Furthermore do not forget, guys, which one always are able to in this publication locate solutions to address the most the very confusing queries. We attempted — lay out the complete content using the very easy-to-grasp method.
Доброго времени Цены космос а качество мыло То кромка отклеивается через месяц Короче, единственные кто не наваривается в тридорога — кухни на заказ в спб с фурнитурой Blum Замерщик приехал на следующий день В общем, жмите чтобы не потерять контакт — кухни спб https://kuhni-spb-wxh.ru Проверяйте производителя по этому списку Сам столько нервов потратил теперь делюсь опытом
На нашем сайте легко найти обилие ценной информации.
Здесь содержатся статьи и руководства на различный вкус.
Пользователь в состоянии получить как широкую базу, так и узкопрофильные кейсы.
Данный портал способен помочь профессионалам в их практике.
https://1-mk.ru/detail/129-tulskaya-rabotnitsa-poluchit-60-tysyach-za-to-chto-eyo-telo-zaplatilo-za-chuzhoy-veter-na-proizvodstve/
Кроме того на портале регулярно публикуются актуальные материалы.
Советуем подробно изучить собранную здесь базу.
Следовательно, данный ресурс является отличным кладезем полезностей.
Помощь в продаже новостроек от застройщиков, узнайте все детали <a href=
https://www.doyoubuzz.com/ayaxru-ayaxru
Продолжение kraken онион
mexican pharmacy online: mexico pharmacy – CasaSalud Pharmacy
At this time it seems like Expression Engine is the preferred blogging platform available right now. (from what I’ve read) Is that what you are using on your blog?
CasaSalud Pharmacy mexican pharmacy online mexican online pharmacy