-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JaxRS-Java] issue with implFolder on windows, and required fields generation for containers #88
Conversation
This fix is for the issue: swagger-api/swagger-codegen#8113 When using jaxrs-cxf-cdi and other JaxRS generators, the implFolder config is not honored by hte generator on windows.
Change similar to https://github.com/swagger-api/swagger-codegen/pull/5363/files for jax-rs-cdi generator. When a property that is a contained is not declared as required, it is initialized to `null`, and not to the empty container. This makes apio mich more easy to use, since one can differentiate when an input list in json has been set to the empty array or simply not set.
@@ -33,12 +38,37 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali | |||
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} | |||
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") | |||
@JsonProperty("{{baseName}}") | |||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { | |||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about the {{#isBoolean}}is{{/isBoolean}}{{getter}}
syntax? because I have removed it in OpenAPI Generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, right, thanks !
It looks like I pulled this change from the original one I did for swagger-codegen by error. Correcting it just now.
As noted by @jmini, do not use the {{#isBoolean}}is{{/isBoolean}}{{getter}} syntax, that was removed from the OpenAPI Generator.
This looks good to me. Thank you for this contribution! I have run ---
.../gen/java/org/openapitools/model/Category.java | 4 ++++
.../org/openapitools/model/ModelApiResponse.java | 6 +++++
.../src/gen/java/org/openapitools/model/Order.java | 12 ++++++++++
.../src/gen/java/org/openapitools/model/Pet.java | 27 +++++++++++++++++++++-
.../src/gen/java/org/openapitools/model/Tag.java | 4 ++++
.../src/gen/java/org/openapitools/model/User.java | 16 +++++++++++++
6 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Category.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Category.java
index ab374c7..041542f 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Category.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Category.java
@@ -19,8 +19,10 @@ import javax.xml.bind.annotation.*;
public class Category {
private Long id = null;
+
private String name = null;
+
/**
**/
public Category id(Long id) {
@@ -38,6 +40,7 @@ public class Category {
this.id = id;
}
+
/**
**/
public Category name(String name) {
@@ -56,6 +59,7 @@ public class Category {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/ModelApiResponse.java
index fd2cca1..26f2c5d 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/ModelApiResponse.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/ModelApiResponse.java
@@ -19,9 +19,12 @@ import javax.xml.bind.annotation.*;
public class ModelApiResponse {
private Integer code = null;
+
private String type = null;
+
private String message = null;
+
/**
**/
public ModelApiResponse code(Integer code) {
@@ -39,6 +42,7 @@ public class ModelApiResponse {
this.code = code;
}
+
/**
**/
public ModelApiResponse type(String type) {
@@ -56,6 +60,7 @@ public class ModelApiResponse {
this.type = type;
}
+
/**
**/
public ModelApiResponse message(String message) {
@@ -74,6 +79,7 @@ public class ModelApiResponse {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Order.java
index 523d105..7bc6a61 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Order.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Order.java
@@ -19,10 +19,14 @@ import javax.xml.bind.annotation.*;
public class Order {
private Long id = null;
+
private Long petId = null;
+
private Integer quantity = null;
+
private java.util.Date shipDate = null;
+
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
public enum StatusEnum {
@@ -56,8 +60,10 @@ public enum StatusEnum {
}
private StatusEnum status = null;
+
private Boolean complete = false;
+
/**
**/
public Order id(Long id) {
@@ -75,6 +81,7 @@ public enum StatusEnum {
this.id = id;
}
+
/**
**/
public Order petId(Long petId) {
@@ -92,6 +99,7 @@ public enum StatusEnum {
this.petId = petId;
}
+
/**
**/
public Order quantity(Integer quantity) {
@@ -109,6 +117,7 @@ public enum StatusEnum {
this.quantity = quantity;
}
+
/**
**/
public Order shipDate(java.util.Date shipDate) {
@@ -126,6 +135,7 @@ public enum StatusEnum {
this.shipDate = shipDate;
}
+
/**
* Order Status
**/
@@ -144,6 +154,7 @@ public enum StatusEnum {
this.status = status;
}
+
/**
**/
public Order complete(Boolean complete) {
@@ -162,6 +173,7 @@ public enum StatusEnum {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Pet.java
index 9c993d8..32e0792 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Pet.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Pet.java
@@ -23,10 +23,15 @@ import javax.xml.bind.annotation.*;
public class Pet {
private Long id = null;
+
private Category category = null;
+
private String name = null;
+
private List<String> photoUrls = new ArrayList<String>();
- private List<Tag> tags = new ArrayList<Tag>();
+
+ private List<Tag> tags = null;
+
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
@@ -62,6 +67,7 @@ public enum StatusEnum {
private StatusEnum status = null;
+
/**
**/
public Pet id(Long id) {
@@ -79,6 +85,7 @@ public enum StatusEnum {
this.id = id;
}
+
/**
**/
public Pet category(Category category) {
@@ -96,6 +103,7 @@ public enum StatusEnum {
this.category = category;
}
+
/**
**/
public Pet name(String name) {
@@ -114,6 +122,7 @@ public enum StatusEnum {
this.name = name;
}
+
/**
**/
public Pet photoUrls(List<String> photoUrls) {
@@ -132,6 +141,12 @@ public enum StatusEnum {
this.photoUrls = photoUrls;
}
+ public Pet addPhotoUrlsItem(String photoUrlsItem) {
+ this.photoUrls.add(photoUrlsItem);
+ return this;
+ }
+
+
/**
**/
public Pet tags(List<Tag> tags) {
@@ -149,6 +164,15 @@ public enum StatusEnum {
this.tags = tags;
}
+ public Pet addTagsItem(Tag tagsItem) {
+ if (this.tags == null) {
+ this.tags = new ArrayList<Tag>();
+ }
+ this.tags.add(tagsItem);
+ return this;
+ }
+
+
/**
* pet status in the store
**/
@@ -168,6 +192,7 @@ public enum StatusEnum {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Tag.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Tag.java
index c39e15a..3f27a3b 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Tag.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/Tag.java
@@ -19,8 +19,10 @@ import javax.xml.bind.annotation.*;
public class Tag {
private Long id = null;
+
private String name = null;
+
/**
**/
public Tag id(Long id) {
@@ -38,6 +40,7 @@ public class Tag {
this.id = id;
}
+
/**
**/
public Tag name(String name) {
@@ -56,6 +59,7 @@ public class Tag {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
diff --git a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/User.java b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/User.java
index 3b1d5e7..f481ec8 100644
--- a/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/User.java
+++ b/samples/server/petstore/jaxrs-cxf-cdi/src/gen/java/org/openapitools/model/User.java
@@ -19,14 +19,22 @@ import javax.xml.bind.annotation.*;
public class User {
private Long id = null;
+
private String username = null;
+
private String firstName = null;
+
private String lastName = null;
+
private String email = null;
+
private String password = null;
+
private String phone = null;
+
private Integer userStatus = null;
+
/**
**/
public User id(Long id) {
@@ -44,6 +52,7 @@ public class User {
this.id = id;
}
+
/**
**/
public User username(String username) {
@@ -61,6 +70,7 @@ public class User {
this.username = username;
}
+
/**
**/
public User firstName(String firstName) {
@@ -78,6 +88,7 @@ public class User {
this.firstName = firstName;
}
+
/**
**/
public User lastName(String lastName) {
@@ -95,6 +106,7 @@ public class User {
this.lastName = lastName;
}
+
/**
**/
public User email(String email) {
@@ -112,6 +124,7 @@ public class User {
this.email = email;
}
+
/**
**/
public User password(String password) {
@@ -129,6 +142,7 @@ public class User {
this.password = password;
}
+
/**
**/
public User phone(String phone) {
@@ -146,6 +160,7 @@ public class User {
this.phone = phone;
}
+
/**
* User Status
**/
@@ -165,6 +180,7 @@ public class User {
}
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
--
2.10.1
Have you a way to run the script and to add the commit on this PR? |
This updates the petstore sample
I executed the script, the diff is exactly the one you had. |
And I think this is the result you expected from your description:
So this looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone else wants to have a look at it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
* master: (36 commits) jaxrs-cxf-cdi: fix outer enum (OpenAPITools#131) Move bash argv opt to end of ags line in scripts (OpenAPITools#124) Reduce CI logging (OpenAPITools#119) Download elm dependencies without prompting user. (OpenAPITools#118) [aspnetcore] Make the use of Swashbuckle optional (OpenAPITools#110) DefaultGenerator: fix NullPointerException (OpenAPITools#109) [Java] use html entities in javadoc of generated code (OpenAPITools#106) Update PULL_REQUEST_TEMPLATE.md [java] Enum in array of array (OpenAPITools#66) Rename datatype to dataType in CodegenProperty (OpenAPITools#69) update elm test to compile all elm files (OpenAPITools#95) Fix Petstore example for Elm (OpenAPITools#96) Update Docker documentation (OpenAPITools#97) CaseFormatLambda has been added, params for Rest-assured client has been refactored (OpenAPITools#91) Update integration.md [Clojure] Add util method to set the api-context globally (OpenAPITools#93) [JaxRS-Java] issue with implFolder on windows, and required fields generation for containers (OpenAPITools#88) Set parameters allowableValues dynamically (OpenAPITools#65) Meta: set version for "build-helper-maven-plugin" (OpenAPITools#89) Fix javadoc issues in "openapi-generator" module (OpenAPITools#84) ...
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
.Description of the PR
This fix is for the issue: [JaxRS] Code generator does not honor implFolder on windows platform swagger-api/swagger-codegen#8113
When using jaxrs-cxf-cdi and other JaxRS generators, the implFolder
config is not honored by the generator on windows.
Change similar to https://github.com/swagger-api/swagger-codegen/pull/5363/files for jax-rs-cdi generator.
When a property that is a contained is not declared as required, it is initialized to
null
, and not to the empty container.This makes api much more easy to use, since one can differentiate when an input list in json has been set to the empty array or simply not set.