swagger-codegen

Generate java classes using swagger and yaml

五迷三道 提交于 2020-01-03 04:56:06
问题 I would to generate my Java classes using the maven plugin swagger-codegen-maven-plugin version 2.2.3 . Here my pom.xml file with the configuration: <plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>2.2.3</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>${basedir}/src/main/resources/swagger/project.yaml</inputSpec> <language>java</language> <configOptions> <sourceFolder>src/gen/java/main<

Update code generated by Swagger code-gen

我只是一个虾纸丫 提交于 2020-01-01 05:18:13
问题 I have generated the code from swagger.yaml file using swagger code-gen in spring. Now I have updated the swagger.yaml file for my API and added few more HTTP operations. Will it be possible to update the existing code generated previously automatically without merging it manually? 回答1: I guess you are talking about the Controllers generated by codegen, that you have then implemented. They are overwritten after each generation, which means you will have to manually merge the code to add the

How to generate swagger.json using gradle?

六眼飞鱼酱① 提交于 2019-12-30 00:28:10
问题 I want to use swagger-codegen to generate REST clients and possibly static HTML documentation. However, swagger-codegen needs swagger.json for input. I am aware, that I can get this from a running REST server equipped with Swagger. But is there a way to obtain swagger.json directly from my Java code - i.e. to generate it with gradle from the source code - without the need to run the application in a web container, and pointing curl or a browser to it? 回答1: This is a bit old but I was

How to document dynamic query parameter names in OpenAPI (Swagger)?

家住魔仙堡 提交于 2019-12-28 04:26:19
问题 Is there any way to document the following query? GET api/v1/users?name1=value1&name2=value where the query parameter names are dynamic and will be received from the client. I'm using the latest Swagger API. 回答1: Free-form query parameters can be described using OpenAPI 3.0, but not OpenAPI 2.0 (Swagger 2.0). The parameter should have type: object with the serialization method style: form and explode: true . The object will serialized as ?prop1=value1&prop2=value2&... , where individual prop

Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12

梦想的初衷 提交于 2019-12-25 07:17:07
问题 Hi Im new to swagger and It was a while since I developed for Android - haven't understood all with the gradle files etc. Im stuck with this problem with dependency to the JUnit 4.12 I have a project that I wan't to merge with a project created with a project generated with swagger-codegen I have imported the source but now I'm stuck with getting to resolve Junit:2.14 Failed to resolve: junit:junit:4.12 I have tried to add it to gradlebuild diffrent ways and read some where that you sould add

Returning an array of objects that properly defines the SDK response

℡╲_俬逩灬. 提交于 2019-12-24 10:58:06
问题 I have a typical RESTful endpoint that returns a collection of models, but the generated Ruby SDK returns a new model, Matters instead of an array of models. I can hack at the generated source code to return Array<Matter> but that is a maintenance headache. How do I specify that I want to return Array<Matter> in the YAML? paths: /matters: get: ... responses: 200: schema: $ref: "#/definitions/Matters" ... definitions: Matter: type: "object" properties: id: type: "string" description: "Database

Import swagger-codegen project into existing Android project

亡梦爱人 提交于 2019-12-23 17:05:47
问题 Im trying to integrate a "module"-project generated by swagger-codegen, into my Android project. Haven't worked that much with gradle before and the swagger-codegen creates a quite messy build.gradle from my point of view. I have a hard time finding documentation on how to do this. And I feel a bit lost. I used this method described in the FAQ mvn clean package java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -i http://petstore.swagger.io/v2/swagger.json \ -l

Why if (arg0.length > 0 && arg0[0].equals(“exitcode”))?

好久不见. 提交于 2019-12-23 02:47:14
问题 I found this SpringBoot Application code which throws Exit Code 10 when executed with argument "exitcode". public class Swagger2SpringBoot implements CommandLineRunner { @Override public void run(String... arg0) throws Exception { if (arg0.length > 0 && arg0[0].equals("exitcode")) { throw new ExitException(); } } public static void main(String[] args) throws Exception { new SpringApplication(SpringBootEntityApp.class).run(args); } class ExitException extends RuntimeException implements

How to bundle Swagger generated code with webpack

眉间皱痕 提交于 2019-12-22 10:18:27
问题 I'm creating a new webApp that needs to communicate with the server using a REST API. I want to use Swagger to define the REST API and to generate the code for the server and the Javascript client (a simple webapp running in a browser). I was able to implement the server (using a Java servlet) and it works. I have generated the code for the Javascript client but I'm not able to make it works (I'm a very beginner in Javascript, webpack, nom...). I want to use webpack to generate a .js file

swagger-codegen client: How to include jackson annotations on models

梦想与她 提交于 2019-12-22 09:49:22
问题 I'm using swagger-codegen to generate a rest client, but I get a problem, the service I'm consuming returns a model with an inheritance, the API model looks like this: public class Person { private List<Book> books; ... } @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "typeClass") @JsonSubTypes({ @JsonSubTypes.Type(value = Magazine.class) }) public class Book { //some prop } @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY,