NestJS codegen from Swagger API definition - swagger

Does anybody know of a way to automatically generate NestJS typescript code from Swagger?

Currently, there are no packages that build a Nest server based on a swagger.json file. Would be a cool project though

Just found a project that claims it can generate Nest.js code from a Swagger / OpenAPI spec file:
         swagger-nestjs-codegen on Github and on npmjs.com
Did not test it yet, though.

Related

What is the difference between Swagger UI vs Swagger CodeGen?

What is the difference between Swagger UI vs Swagger CodeGen?
I read the description in https://swagger.io/tools/. It sounds like Swagger Editor, UI, and codeGen are totally different tools. If I want to generate .Net server stubs and visualize them, does it mean I need to use both UI and CodeGen?
Yes, they are different tools for different purposes.
Swagger UI is a documentation renderer, basically an HTML page. You point it to an OpenAPI definition (YAML or JSON file), and Swagger UI produces API documentation that looks like this. You can host it on your website.
Swagger Editor is an editor where you can write OpenAPI definitions manually, or load/paste arbitrary OpenAPI definitions to check them for syntax errors. Swagger Editor also has Swagger Codegen integrated into it, accessible via the "Generate Server" and "Generate Client" menus.
Swagger Codegen is a code generator. You can use it to generate server stubs and client SDKs from an OpenAPI definition. For example, here's how to generate an ASP.NET server stub using Swagger Codegen CLI (line breaks added for readability):
java -jar swagger-codegen-cli-3.0.21.jar generate
-i https://petstore.swagger.io/v2/swagger.yaml
-l aspnetcore
-o .\aspnetcore-server

aspnetcore is missing from Codegen Options in SwaggerHub

for me, aspnetcore is missing from Codegen Options in SwaggerHub.
Am I making some simple mistake?
I just want to generate server stub from existing openapi file.
thank you.
figured out myself - when creating an new API in SwaggerHub, you should go with OpenAPI Version 2.0 , not 3.0 if you want to have Server Stub generation option.

How do I modify the status code in a HTTP response in swagger

I have a swagger .yaml file and I am using codegen to create a spring boot application.How can I modify the HTTP response in swagger.
It seems that codegen does not work as you said. This app generates a simple code. I advice you to use the following generator for Spring Boot (named as "Spring MVC"):
https://github.com/BBVA-CIB/APIRestGenerator

Whats the right swagger tool/plugin to generate Swagger 2.0 jsons out of JaxRS annoations which works with ANT?

We use Apache Ant for our project build and were thinking of extending the same for getting swagger 2.0 specs .json generated for our REST API docs. I found an ant task : https://github.com/cstroe/swagger-ant-task
which would invoke the same swagger core maven plugin, but some dependency jars have been changed in the github package due to which I am getting 'No Such Method' Exception for getApiInfo() method in ApiSourceInfo.java.
We cannot use maven just for generating API docs. I needed some help in finding a way by which I can use swagger core tool of generating docs using swagger annotations in the API definition file. Using ant wrapper for the maven plugin was one way but I am not not able to leverage it. Is there any other workaround?
Or to frame it otherwise, whats the right swagger tool/plugin to generate Swagger 2.0 jsons out of JaxRS annoations which works with ANT.
Any suggestion would be much appreciated.
Thanks

Swagger spec in Swagger Core Jersey 1.X

I am using Swagger with Jersey 1. It generates spec in Swagger spec v1.2. Most of the tools out there (e.g. Editor ) require spec v2.0. Is there a way to generate spec v2.0 ?
I actually wanted printable/static docs like bootprint-swagger which also required spec v2.0.
I have not tried it myself, but https://github.com/lucybot/api-spec-converter seems to be able to convert Swagger 1.2 to Swagger 2.0
I'm not sure if it is an "official" Swagger-Tool, but it is just two clicks away from the Swagger-1.2-to-2.0-Migration-Guide, so I guess its like "half-official" at least.
I might try to incoorporate it into bootprint-swagger so that it supports Swagger 1.2 as well. I've just created an issue at github so that it is not forgotten.

Resources