3 ms·
I use swashbuckle and swagger-typescript-api to automatically scrape my controllers and generate API calls and TS types every time I rebuild. No hassle or overh
by JackMorgan 3y ago
I use swashbuckle and swagger-typescript-api to automatically scrape my controllers and generate API calls and TS types every time I rebuild. No hassle or overhead at all. No need for converters or anything.
I've been using this now for several projects, it's a great way to have all the power of TS for client side and C# for server side.
https://www.npmjs.com/package/swagger-typescript-api https://www.npmjs.com/package/swagger-typescript-api
https://www.nuget.org/packages/Swashbuckle https://www.nuget.org/packages/Swashbuckle
- CharlieDigital 3y agoI do the same. I have a small write-up here: https://chrlschn.dev/blog/2023/10/end-to-end-type-safety-with-dotnet7-webapis-typescript-openapi/ https://chrlschn.dev/blog/2023/10/end-to-end-type-safety-wit... You get end-to-end type safety (even better once you connect it to EF Core since you get it all ways to your DB). With this setup with hot-reload (currently broken in .NET 8 [0]), productivity is really, really good. Like tRPC but with one of the most powerful ORMs out there right now. [0] https://github.com/dotnet/sdk/issues/36918 https://github.com/dotnet/sdk/issues/36918
- aerhardt 3y agoI do the same in Django with drf-spectacular. I have a precommit hook that autogenerates (fairly thin) TypeScript schemas and routes on commit. This is not take merit from LOB devs who want to use C# back-to-front. I will use it as an argument to those who say that this is why you should go full TypeScript on any new web project though.
- switch007 3y agoN.B. the last commit/release for Swashbuckle was Jan this year. https://github.com/RicoSuter/NSwag https://github.com/RicoSuter/NSwag might be a better choice for a new project. It look much more maintained and active than Swashbuckle
- dustymcp 3y agoyeah nswag has been pretty consistent i can recommend aswell.