4 ms·
Can't you already do this using Swagger Codegen? I use swashbuckle to automatically generate swagger https://www.nuget.org/packages/Swashbuckle/ https://www.nu
by petilon 9y ago
Can't you already do this using Swagger Codegen?
I use swashbuckle to automatically generate swagger
https://www.nuget.org/packages/Swashbuckle/ https://www.nuget.org/packages/Swashbuckle/
Then paste swagger definition into the online editor to generate TypeScript client: https://swagger.io/swagger-editor/ https://swagger.io/swagger-editor/
(You can also generate offline).
How is RESTyped better than Swagger Codgen?
- rawrmaan 9y agoThis is pretty cool, I hadn't seen it before! RESTyped has a couple of advantages over this: - RESTyped definitions are extremely lightweight and don't require shipping an API wrapper with a bunch of generated code - No build/manual copy step required. Easy to distribute typings on NPM.
- petilon 9y agoSwagger is a de facto standard for automatically generating JSON descriptions of REST API and for generating UI for invoking/experimenting with REST APIs. Swagger codegen is good but not terrific. Alternatives would be welcome. I recommend layering your code gen over swagger.
- daotoad 9y agoSwagger is the basis and a great implementation of OpenAPI which is a standard. https://www.openapis.org https://www.openapis.org
- kevinoid 9y agoI don't understand the advantages, could you clarify? - In what way are RESTyped definitions lighter? A Swagger definition is just a JSON or YAML file and can be used without shipping any additional code (e.g. by https://github.com/swagger-api/swagger-js https://github.com/swagger-api/swagger-js). - Swagger only requires a build step when the definition is used to generate code. Definitions can be distributed via NPM (e.g. https://www.npmjs.com/package/appveyor-swagger https://www.npmjs.com/package/appveyor-swagger). Edit: I realized you were talking about RESTyped being lighter/nobuild compared to Swagger Codegen specifically for TypeScript because it is written in TypeScript. Seems reasonable.