mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Fix assignment of new object instance to variable (#7379)
* #7359 Fix - use reflection to instantiate non-generated class (#7360) * add tests for java vertx petstore * add swagger example to README.md (#7368) * Fix assignment of new object instance to variable Fixes `Error in foobar$fromJSONString(s) : object 'CategoryObject' not found` Discussion in https://github.com/swagger-api/swagger-codegen/issues/6520#issuecomment-357132746 , thanks @wing328 for encouraging.
This commit is contained in:
parent
0f6696089f
commit
9e06f7063f
@ -929,6 +929,7 @@ Presentations/Videos/Tutorials/Books
|
||||
- 2017/12/07 - [API-driven development with OpenAPI and Swagger, Part 2](https://www.itworld.com/article/3199190/apis/api-driven-development-with-openapi-and-swagger-part-2.html) by Matthew Tyson
|
||||
- 2017/12/29 - [REST APIs代码生成指南](https://gumroad.com/l/swagger_codegen_beginner_zh)(eBook) by [William Cheng](https://github.com/wing328), [Xin Meng](https://github.com/xmeng1)
|
||||
- 2017/12/21 - [Using Protocol Buffer to Generate SDK at Hootsuite](http://code.hootsuite.com/using-protocol-buffer-to-generate-sdk-at-hoosuite/?lipi=urn%3Ali%3Apage%3Ad_flagship3_messaging%3By4ATz3SDRXyvXJJ14LQysQ%3D%3D) by [Joy Zhang](https://www.linkedin.com/in/joy8zhang/)
|
||||
- 2018/01/11 - [Swagger 工具箱介绍及代码自动生成示例](https://github.com/qct/swagger-example) by [qct](https://github.com/qct)
|
||||
|
||||
# Swagger Codegen Core Team
|
||||
|
||||
|
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-vertx -o samples/server/petstore/java-vertx/rx -DvertxSwaggerRouterVersion=1.2.0,rxInterface=true"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-vertx --artifact-id swagger-java-vertx-rx-server -o samples/server/petstore/java-vertx/rx -DvertxSwaggerRouterVersion=1.2.0,rxInterface=true"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -19,8 +19,17 @@ public class {{classname}}Verticle extends AbstractVerticle {
|
||||
|
||||
{{#operations}}{{#operation}}{{#vendorExtensions}}final static String {{x-serviceid-varname}} = "{{x-serviceid}}";
|
||||
{{/vendorExtensions}}{{/operation}}{{/operations}}
|
||||
//TODO : create Implementation
|
||||
{{classname}} service = new {{classname}}Impl();
|
||||
final {{classname}} service;
|
||||
|
||||
public {{classname}}Verticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("{{package}}.{{classname}}Impl");
|
||||
service = ({{classname}})serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("{{classname}}Verticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -127,7 +127,7 @@
|
||||
self$`{{baseName}}` <- lapply({{classname}}Object$`{{baseName}}`, function(x) {{datatype}}$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{datatype}}Object -> {{datatype}}$new()
|
||||
{{datatype}}Object <- {{datatype}}$new()
|
||||
self$`{{baseName}}` <- {{datatype}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
{{/isListContainer}}
|
||||
{{/isPrimitiveType}}
|
||||
|
@ -843,8 +843,10 @@
|
||||
<!-- test non-java projects -->
|
||||
<module>samples/client/petstore/go</module>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/java-vertx/rx</module>
|
||||
<module>samples/server/petstore/java-vertx/async</module>
|
||||
<module>samples/server/petstore/java-inflector</module>
|
||||
<module>samples/server/petstore/java-pkmst</module>
|
||||
<module>samples/server/petstore/java-pkmst</module>
|
||||
<module>samples/server/petstore/java-play-framework</module>
|
||||
<module>samples/server/petstore/undertow</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey1</module>
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.1-SNAPSHOT
|
@ -15,7 +15,7 @@
|
||||
<junit.version>4.12</junit.version>
|
||||
<vertx.version>3.4.1</vertx.version>
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<vertx-swagger-router.version>1.2.0</vertx-swagger-router.version>
|
||||
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
|
||||
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
||||
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
||||
</properties>
|
||||
@ -28,25 +28,24 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -88,4 +87,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
@ -28,8 +28,17 @@ public class PetApiVerticle extends AbstractVerticle {
|
||||
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
|
||||
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
|
||||
|
||||
//TODO : create Implementation
|
||||
PetApi service = new PetApiImpl();
|
||||
final PetApi service;
|
||||
|
||||
public PetApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.PetApiImpl");
|
||||
service = (PetApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("PetApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -22,8 +22,17 @@ public class StoreApiVerticle extends AbstractVerticle {
|
||||
final static String GETORDERBYID_SERVICE_ID = "getOrderById";
|
||||
final static String PLACEORDER_SERVICE_ID = "placeOrder";
|
||||
|
||||
//TODO : create Implementation
|
||||
StoreApi service = new StoreApiImpl();
|
||||
final StoreApi service;
|
||||
|
||||
public StoreApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.StoreApiImpl");
|
||||
service = (StoreApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("StoreApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -26,8 +26,17 @@ public class UserApiVerticle extends AbstractVerticle {
|
||||
final static String LOGOUTUSER_SERVICE_ID = "logoutUser";
|
||||
final static String UPDATEUSER_SERVICE_ID = "updateUser";
|
||||
|
||||
//TODO : create Implementation
|
||||
UserApi service = new UserApiImpl();
|
||||
final UserApi service;
|
||||
|
||||
public UserApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.UserApiImpl");
|
||||
service = (UserApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("UserApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.1-SNAPSHOT
|
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-java-vertx-server</artifactId>
|
||||
<artifactId>swagger-java-vertx-server-rx</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<junit.version>4.12</junit.version>
|
||||
<vertx.version>3.4.1</vertx.version>
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<vertx-swagger-router.version>1.2.0</vertx-swagger-router.version>
|
||||
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
|
||||
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
||||
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
||||
</properties>
|
||||
@ -28,25 +28,24 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -88,4 +87,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
@ -28,8 +28,17 @@ public class PetApiVerticle extends AbstractVerticle {
|
||||
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
|
||||
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
|
||||
|
||||
//TODO : create Implementation
|
||||
PetApi service = new PetApiImpl();
|
||||
final PetApi service;
|
||||
|
||||
public PetApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.PetApiImpl");
|
||||
service = (PetApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("PetApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -22,8 +22,17 @@ public class StoreApiVerticle extends AbstractVerticle {
|
||||
final static String GETORDERBYID_SERVICE_ID = "getOrderById";
|
||||
final static String PLACEORDER_SERVICE_ID = "placeOrder";
|
||||
|
||||
//TODO : create Implementation
|
||||
StoreApi service = new StoreApiImpl();
|
||||
final StoreApi service;
|
||||
|
||||
public StoreApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.StoreApiImpl");
|
||||
service = (StoreApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("StoreApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
@ -26,8 +26,17 @@ public class UserApiVerticle extends AbstractVerticle {
|
||||
final static String LOGOUTUSER_SERVICE_ID = "logoutUser";
|
||||
final static String UPDATEUSER_SERVICE_ID = "updateUser";
|
||||
|
||||
//TODO : create Implementation
|
||||
UserApi service = new UserApiImpl();
|
||||
final UserApi service;
|
||||
|
||||
public UserApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.UserApiImpl");
|
||||
service = (UserApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("UserApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
Loading…
x
Reference in New Issue
Block a user