Skip to content

Commit aa591cf

Browse files
authored
Merge pull request #458 from swagger-api/codegen-issue9203
refs swagger-api/swagger-codegen#9203 - Remove duplicated `isis` boolean property getter and other java fixes
2 parents ed82a4a + a9baeba commit aa591cf

File tree

20 files changed

+36
-30
lines changed

20 files changed

+36
-30
lines changed

src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,9 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
947947
}
948948
if (model.discriminator != null && model.discriminator.getPropertyName().equals(property.baseName)) {
949949
property.vendorExtensions.put("x-is-discriminator-property", true);
950-
model.imports.add("JsonTypeId");
950+
if (additionalProperties.containsKey("jackson")) {
951+
model.imports.add("JsonTypeId");
952+
}
951953
}
952954
}
953955

src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaJAXRSServerCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
9595
if (!this.additionalProperties.containsKey("serverPort")) {
9696
final URL urlInfo = URLPathUtil.getServerURL(openAPI);
9797
String port = "8080"; // Default value for a JEE Server
98-
if ( urlInfo != null && urlInfo.getPort() != 0) {
99-
port = String.valueOf(urlInfo.getPort());
98+
if ( urlInfo != null && urlInfo.getPort() > 0) {
99+
port = String.valueOf(urlInfo.getPort());
100100
}
101101
this.additionalProperties.put("serverPort", port);
102102
}

src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,6 @@ public void setParameterExampleValue(CodegenParameter p) {
720720
}
721721
}
722722

723-
public String toBooleanGetter(String name) {
724-
return getterAndSetterCapitalize(name);
725-
}
726-
727723
public void setTitle(String title) {
728724
this.title = title;
729725
}

src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
4141
{{#useOas2}}@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useOas2}}
4242
{{^useOas2}}@Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useOas2}}
4343
@JsonProperty("{{baseName}}")
44-
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
44+
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
4545
return {{name}};
4646
}
4747
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#interfa
6969
{{#vendorExtensions.extraAnnotation}}
7070
{{{vendorExtensions.extraAnnotation}}}
7171
{{/vendorExtensions.extraAnnotation}}
72-
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#is this 'enum'}}{{#isNot this 'list-container'}}{{#isNot this 'map-container'}}public {{datatype}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
72+
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#is this 'enum'}}{{#isNot this 'list-container'}}{{#isNot this 'map-container'}}public {{datatype}} {{getter}}() {
7373
if ({{name}} == null) {
7474
return null;
7575
}
7676
return {{name}}.getValue();
77-
}{{/isNot}}{{/isNot}}{{/is}}{{#is this 'enum'}}{{#is this 'list-container'}}public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
77+
}{{/isNot}}{{/isNot}}{{/is}}{{#is this 'enum'}}{{#is this 'list-container'}}public {{{datatypeWithEnum}}} {{getter}}() {
7878
return {{name}};
79-
}{{/is}}{{/is}}{{#is this 'enum'}}{{#is this 'map-container'}}public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
79+
}{{/is}}{{/is}}{{#is this 'enum'}}{{#is this 'map-container'}}public {{{datatypeWithEnum}}} {{getter}}() {
8080
return {{name}};
8181
}{{/is}}{{/is}}{{#isNot this 'enum'}}public {{{datatypeWithEnum}}} {{getter}}() {
8282
return {{name}};

src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import javax.ws.rs.core.Response;
2929
import javax.ws.rs.core.SecurityContext;
3030
import javax.ws.rs.*;
3131

32-
@Path("/{{{baseName}}}")
32+
{{#apiBasePath}}@Path("/{{{apiBasePath}}}"){{/apiBasePath}}
33+
{{^apiBasePath}}@Path("/{{{baseName}}}"){{/apiBasePath}}
3334
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
3435
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
3536
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
@@ -57,7 +58,7 @@ public class {{classname}} {
5758
{{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
5859
{{/parameters}}@Context SecurityContext securityContext)
5960
throws NotFoundException {
60-
return delegate.{{nickname}}({{#parameters}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext);
61+
return delegate.{{nickname}}({{#parameters}}{{#isFile}} {{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext);
6162
}
6263
{{/contents}}
6364
{{/operation}}

src/main/resources/handlebars/JavaJaxRS/resteasy/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework.
1010
To run the server, please execute the following:
1111

1212
```
13-
mvn clean package jetty:run
13+
mvn clean package
1414
```
1515

1616
You can then view the swagger listing here:

src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pojo.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
4040
@Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}")
4141
{{/useOas2}}
4242
@JsonProperty("{{baseName}}")
43-
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
43+
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
4444
return {{name}};
4545
}
4646
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies {
2222
compile 'io.swagger.core.v3:swagger-annotations:2.0.0'
2323
{{/useOas2}}
2424
compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final'
25+
compile 'org.apache.httpcomponents:httpclient:4.5.10'
2526
{{#useBeanValidation}}
2627
providedCompile 'javax.validation:validation-api:1.1.0.Final'
2728
{{/useBeanValidation}}
@@ -37,7 +38,7 @@ dependencies {
3738
compile 'io.swagger:swagger-jaxrs:1.5.12'
3839
{{/useOas2}}
3940
{{^useOas2}}
40-
compile 'io.swagger.core.v3:swagger-jaxrs2:2.0.0'
41+
compile 'io.swagger.core.v3:swagger-jaxrs2:2.0.9'
4142
{{/useOas2}}
4243

4344
testCompile 'junit:junit:4.12',

src/main/resources/handlebars/JavaJaxRS/resteasy/pojo.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
3535
@Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}")
3636
{{/useOas2}}
3737
@JsonProperty("{{baseName}}")
38-
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() {
38+
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
3939
return {{name}};
4040
}
4141
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

0 commit comments

Comments
 (0)