NSwag - SWAGGER For ASP.NET CORE and AUTOMATIC Type Generation For TypeScript |

  Рет қаралды 23,055

Rahul Nath

Rahul Nath

4 жыл бұрын

Hey Friends, "The OpenAPI Specification, originally known as the Swagger Specification,
is a specification for machine-readable interface files for describing, producing,
consuming, and visualizing RESTful web services"
In this video, I will walk you through on how to set up an OpenAPI spec (Swagger endpoint) for your ASP.NET
Core Web API, using NSwag. NSwag provides tools to generate OpenAPI specs and generate
client code to consume these APIs. I will also show how to automatically generate typescript clients and types to consume the API using MSBuild tasks. Every time we build the
project (csproj), it will automatically generate the associated typescript types from the
Data Transfer Objects (DTO) used in the API Controllers.
This allows us to easily integrate our front-end application without backend APIs, giving us
full type safety. Any time we update our DTO's it will also show the associated errors in our
frontend code right at compile time.
🔗 Source - rahulpnath.visualstudio.com/D...
🔗 NSwag - github.com/RicoSuter/NSwag
🔗 NSwag Studio - github.com/RicoSuter/NSwag/wi...
🔗 NSwag Msbuild - github.com/RicoSuter/NSwag/wi...
Come say hi! ✋
🌍 Blog - rahulpnath.com/
✉ Subscribe to my Newsletter - www.rahulpnath.com/subscribe
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
🎥 Recording Setup and Workflow - www.rahulpnath.com/blog/youtu...
Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Пікірлер: 98
@bigchunk1
@bigchunk1 3 жыл бұрын
My man! You explained this better than anyone else I could find! So many incomplete explanations, but you just walk us through it. Thank you!
@RahulNath
@RahulNath 3 жыл бұрын
Awesome, glad it helped!
@ofnoisealteredtastes6637
@ofnoisealteredtastes6637 2 жыл бұрын
This was an excellent walkthrough. You addressed many potential areas of confusion and your explanation was thorough but perfectly concise. Will be coming back to reference as I adopt NSwag myself, thank you!
@RahulNath
@RahulNath 2 жыл бұрын
Glad you enjoyed it!
@2cool238
@2cool238 4 жыл бұрын
Ok, you took the throne. You are the new boss of making much needed tutorials
@RahulNath
@RahulNath 4 жыл бұрын
Lovely, thanks! 😀
@starman9000
@starman9000 3 жыл бұрын
Another addition for knowledge base to improve! great work! I would like to see CI/CD with Git - TeamCity - Docker - Octopus as well!! Sorry huge list!!! I am addicted to your content, easy to digest!
@RahulNath
@RahulNath 3 жыл бұрын
I plan to do one with docker and DevOps. The trouble with TeamCity is I need to set this up on VM or my laptop. I will do one with OctopusDeploy some time (but can’t guarantee when)
@jamesthompson2122
@jamesthompson2122 3 жыл бұрын
This is the third video of yours I've watched....very clear and concise, like the other two. Well done Rahul
@RahulNath
@RahulNath 3 жыл бұрын
Thank you James. You've made my day and a great Monday start 😀 I am sure you'll like the other videos in the ASP NET Core Series. kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Thank you again for letting me know
@mohammadalinia
@mohammadalinia 2 жыл бұрын
This was really helpful and easy to follow Rahul. I loved the extra tips on how you can avoid code generation on your pipelines. Thank you!
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful! And great to see you comment here 😀
@k7raman
@k7raman 2 жыл бұрын
quality content . Thank you Rahul. it is easy to brush my skills in .net in which I developed more than a year ago. Not a single second of video is waste. I appreciate that you've respected the viewers to provide "To the point" information.
@k7raman
@k7raman 2 жыл бұрын
kudos for sharing shortcuts of IDE also.
@RahulNath
@RahulNath 2 жыл бұрын
Thank you and happy you find it useful. Do check out the full series here bit.ly/asp-net-core-series. Let me know how you find it!
@k7raman
@k7raman 2 жыл бұрын
@@RahulNath KZfaq itself recommended. I found your videos in the feed.
@RahulNath
@RahulNath 2 жыл бұрын
@@k7raman Hope you find it useful!
@nat-moba
@nat-moba 3 жыл бұрын
Finally a step by step tutorial thank u \m/ the official documentation is confusing as hell
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Ricardo and happy it helped you. You might find other interesting videos in my ASP NET Series here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@chadhawley569
@chadhawley569 3 жыл бұрын
Very clear. Great job on this one!
@RahulNath
@RahulNath 3 жыл бұрын
Thanks Chad!
@ognjenvojnovic9778
@ognjenvojnovic9778 3 жыл бұрын
You did so great job it looks like a piece of cake ... well done!
@RahulNath
@RahulNath 3 жыл бұрын
Thanks so much 😊
@elpiruwebmaster
@elpiruwebmaster Жыл бұрын
Muchas gracias, fue de muchas utilidad, las aclaraciones hechas ayudaron a configurar un caso con distintas configuraciones
@RahulNath
@RahulNath Жыл бұрын
Thank you!
@triyuga
@triyuga 4 жыл бұрын
Amazing coincidence! One of my colleagues just implemented swagger in a new project at work...
@RahulNath
@RahulNath 4 жыл бұрын
Yeah such a conincidence that we work together 😀
@dand4485
@dand4485 4 жыл бұрын
Oooops you did it again, so I have to say Excellent job again :)
@RahulNath
@RahulNath 4 жыл бұрын
Thank you the encouragement - It really helps! Do let know if you have any particular videos that you would like to see here. 😀
@TonoNamnum
@TonoNamnum 2 жыл бұрын
This is Amazing! Wish I had seen your videos before.
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful Antonio. Hope you are liking the full series bit.ly/asp-net-core-series
@maurobilotti
@maurobilotti 3 жыл бұрын
Incredible tutorial! Worked like a charm!!
@RahulNath
@RahulNath 3 жыл бұрын
Great to hear!
@DavidReidChannel
@DavidReidChannel 2 жыл бұрын
Hi Rahul, this was extremely helpful. Great video, keep up the good work and thanks for sharing this with us.
@RahulNath
@RahulNath 2 жыл бұрын
Great to hear that David. Do check the full series here bit.ly/asp-net-core-series I am sure you will like it!
@PeterParker-nh9di
@PeterParker-nh9di 3 жыл бұрын
Awesome tutorial! Would love to see how your CI/CD pipeline works for an aspnetcore, typescript react app
@RahulNath
@RahulNath 3 жыл бұрын
Thanks Peter and glad you like it. I don’t have one that covers ASP NET Core and react app. I might do it as a live stream (to save time on editing) 😀 I will post back link here once I do it.
@techrelated2417
@techrelated2417 3 жыл бұрын
Awsome explaination !!! Simply the best!!
@RahulNath
@RahulNath 3 жыл бұрын
Awesome! Glad you like it 😀
@samuellepage3975
@samuellepage3975 3 жыл бұрын
Thanks for the tutorial, helped me at work :)
@RahulNath
@RahulNath 3 жыл бұрын
Great to hear Samuel. Do check out the full series here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP I'm sure you like them 😉
@jessegador
@jessegador 2 жыл бұрын
Very helpful. Thank you.
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful Jesse. Do check out my ASP NET Core series!
@RajaSingh012
@RajaSingh012 3 жыл бұрын
Thanks for the video. It is useful
@RahulNath
@RahulNath 3 жыл бұрын
Glad it was helpful!
@promal2006
@promal2006 2 жыл бұрын
Excellent video!!!!
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it! Do check out the full ASP NET Series here in case you haven't bit.ly/asp-net-core-series
@highwaybird
@highwaybird 8 ай бұрын
Very helpful!
@RahulNath
@RahulNath 8 ай бұрын
Glad it was helpful! Do check out the series bit.ly/asp-net-core-series
@TonyGrayCanada
@TonyGrayCanada Жыл бұрын
Really clear and to the point, excellent work. Unfortunately for me nSwag studio just hangs or crashes on my project and never generates anything.
@abijithmv3739
@abijithmv3739 Жыл бұрын
Great video bro
@RahulNath
@RahulNath Жыл бұрын
Thank you Abijith- Hope you are liking the full ASP Series bit.ly/asp-net-core-series
@akirablac
@akirablac Жыл бұрын
Great video. Your teaching style is awesome. Can you please do the series on .Net Web API unit & integration testing?? Thanks
@RahulNath
@RahulNath Жыл бұрын
Thank you Akira. I’ve a playlist here on testing if that helps kzfaq.info/sun/PL59L9XrzUa-lWi02jkBID4a853wypd2sW Also do check out the ASP Series
@daviad9832
@daviad9832 2 жыл бұрын
your explanation was top notch
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it. Do check out my full series here bit.ly/asp-net-core-series. I am sure you will like it. Let me know in case you get to watch any!
@daviad9832
@daviad9832 2 жыл бұрын
@@RahulNath I have already started that series, it is great. I really appreciate it
@RahulNath
@RahulNath 2 жыл бұрын
@@daviad9832 Glad you are liking it. Do let me know in case you have any topic suggestions!
@AxeFinance-wm1cp
@AxeFinance-wm1cp 10 ай бұрын
I created two project nets 6, first with nswag and second with Swashbuckle, and created a project angular, I don't find any differences
@vikranthreddy1863
@vikranthreddy1863 Жыл бұрын
Great content. Feel free to blink more in your videos. :)
@RahulNath
@RahulNath Жыл бұрын
Glad you like it Vikranth and thank you for the permission. I will from now on 😂Working on my camera presence, guessing the newer videos are different. Do check the full series here bit.ly/asp-net-core-series
@BarbarosYurttagul
@BarbarosYurttagul 7 ай бұрын
I hit the like button. Thanks
@RahulNath
@RahulNath 7 ай бұрын
Glad you liked it. Do checkout the ASP Series bit.ly/asp-net-core-series
@cindy3661
@cindy3661 4 жыл бұрын
Nice one.
@RahulNath
@RahulNath 4 жыл бұрын
Thanks!
@dhirajpandeydhirjpndy
@dhirajpandeydhirjpndy 3 жыл бұрын
Thanks for the detailed video on swagger. One question related to TS support in this spa template, How can we add typescript here. Is it something we have to explicitly do with CRA and replace the content in clientApp folder?
@RahulNath
@RahulNath 3 жыл бұрын
You can either update the create react app to support typescript as mentioned in the post here create-react-app.dev/docs/adding-typescript/ Or you can delete all the contents in ClientApp folder and create a brand new create react app with typescript support create-react-app.dev/docs/getting-started/#creating-a-typescript-app Let know if that helps Dhiraj.
@manasipalkar9794
@manasipalkar9794 4 ай бұрын
Hi Rahul , thanks it was an amazing explanation. Can we do it for angular typescript and using Nswag should be mandatory?
@pvchio
@pvchio 3 жыл бұрын
this is excellent and clear. Thank you. I have a question. What if you are working on an enterprise application and there are tons of controllers, do you also put all type definitions in one file? thanks
@RahulNath
@RahulNath 3 жыл бұрын
Glad it was helpful Charlie. I don't mind putting it in one file, since this is generated code. Unless if there is a reason for it to be in separate files. Are you looking at any particular use cases here?
@pvchio
@pvchio 3 жыл бұрын
@@RahulNath thanks for the quick reply. Hypothetically, there could be name collision if my frontend app talks to two different api solutions. E.g. solution A has a FooModel with three fields, and solution B also has a FooModel but with only two fields. In that case, how can NSwag handle it when generating the types? or it will never be that case? Thanks
@RahulNath
@RahulNath 3 жыл бұрын
@@pvchio There is a related issue here which speaks of a similar problem. Looks like this is not yet fully supported - github.com/RicoSuter/NSwag/issues/828. I have not run into this specific issue.
@KCAbramson
@KCAbramson Жыл бұрын
Great tutorial thanks. I have a Q. Why do you write your own api methods instead of using nswag? Seems like so much work that could be 1-button automated.
@RahulNath
@RahulNath Жыл бұрын
I wasn't aware of this feature or probably it wasn't available back when I recorded this video. But yes that if that helps to speed up the whole process do use that. Thank you for pointing it out here 👍👍
@kpg7882
@kpg7882 2 жыл бұрын
This not explain basics... I.e. how can you add description to API endpoint method in Swagger just by editing c# code? i.e. string name
@RahulNath
@RahulNath 2 жыл бұрын
Added to my backlog video list. I will cover this some time!
@pedroferreira9234
@pedroferreira9234 4 жыл бұрын
What if the clientApp and api are separated resources? Good video btw
@RahulNath
@RahulNath 4 жыл бұрын
You can specify the URL to the API Swagger that needs to be generated. Let know if that helps or you need any additional info
@pedroferreira9234
@pedroferreira9234 4 жыл бұрын
@@RahulNath yes, thx you. Keep the good work
@jasminsabanovic869
@jasminsabanovic869 9 ай бұрын
can we create C# classes with it?
@RahulNath
@RahulNath 7 ай бұрын
yes you can - hope you were able to figure it !
@bisarothub1644
@bisarothub1644 3 жыл бұрын
I hope you could have a tutorial on nswag on mac
@RahulNath
@RahulNath 3 жыл бұрын
Thank you for the suggestion Bisarot. Anything specific you are missing? I guess the NSwag Studio is not available on mac?
@bisarothub1644
@bisarothub1644 2 жыл бұрын
@@RahulNath Im trying to do the nswag CLI on mac but I wasn’t able to generate typescript or angular codes from c#. Maybe using nswag cli, setting it up and generating typescript? 😁
@RahulNath
@RahulNath 2 жыл бұрын
@@bisarothub1644 Thank you for the suggestion. Are you using .NET project? I show how to set this up as part of msbuild at 13:30.
@RaviKumar-mq8fv
@RaviKumar-mq8fv Жыл бұрын
bhai basic se banao
@RahulNath
@RahulNath Жыл бұрын
Is it missing any details ?
@RaviKumar-mq8fv
@RaviKumar-mq8fv Жыл бұрын
@@RahulNath what you created only for professional,Beginner can not understand.You want to make then start from basic.Then it will be helpful.
@Felix-og7pd
@Felix-og7pd Жыл бұрын
consume API nswag.json
@RahulNath
@RahulNath Жыл бұрын
Was that a question? Hope you liked the video
@Felix-og7pd
@Felix-og7pd Жыл бұрын
@@RahulNath Not exactly. Just my notes
Connect .Net Core to Azure Key Vault in Ten Minutes
10:26
Rahul Nath
Рет қаралды 55 М.
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 129 МЛН
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 926 М.
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 36 МЛН
Женская драка в Кызылорде
00:53
AIRAN
Рет қаралды 478 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 106 М.
Swagger is Going Away in .NET 9!
10:48
Nick Chapsas
Рет қаралды 91 М.
You don't need a frontend framework
15:45
Andrew Schmelyun
Рет қаралды 116 М.
How to Generate C# Http Client in NSwag Swagger codegen Swashbuckle
14:17
ДОМАШНЕЕ ЭСКИМО//ПРОВЕРКА РЕЦЕПТА ТИК ТОК
0:24
ОЛЯ ПЕРЧИК
Рет қаралды 2,5 МЛН
Попадет ли ему вода в нос?🧐 #моястихия #swimming #юмор #fun
0:33
МОЯ СТИХИЯ | ПЛАВАНИЕ | МОСКВА
Рет қаралды 2,7 МЛН
архив.. Северные Дачи Угледара 23..
0:15
Виталик
Рет қаралды 13 МЛН
На сколько опасна рыба меч?
0:40
Fact Fusion
Рет қаралды 2,9 МЛН
ToRung short film: 🤫pick up money💵🤑
0:26
ToRung
Рет қаралды 8 МЛН