Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.swagger.codegen.CodegenResponse;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.languages.features.BeanValidationFeatures;
import io.swagger.codegen.languages.features.UseGenericResponseFeatures;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
Expand Down Expand Up @@ -139,7 +138,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
if ( operations != null ) {
@SuppressWarnings("unchecked")
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for ( CodegenOperation operation : ops ) {
for ( final CodegenOperation operation : ops ) {
boolean isMultipartPost = false;
List<Map<String, String>> consumes = operation.consumes;
if(consumes != null) {
Expand All @@ -161,23 +160,50 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {

List<CodegenResponse> responses = operation.responses;
if ( responses != null ) {
for ( CodegenResponse resp : responses ) {
for ( final CodegenResponse resp : responses ) {
if ( "0".equals(resp.code) ) {
resp.code = "200";
}

final String responseReturnType = resp.dataType;
// set vendorExtensions.x-java-is-response-void to true as dataType is set to "void"
if (resp.dataType == null) {
if (responseReturnType == null) {
resp.vendorExtensions.put("x-java-is-response-void", true);
}


String rt = responseReturnType;
if (rt == null || rt.trim().isEmpty()) {
resp.dataType = "Void";
resp.baseType = "Void";
} else if (rt.startsWith("List")) {
int end = rt.lastIndexOf(">");
if (end > 0) {
resp.dataType = rt.substring("List<".length(), end).trim();
resp.baseType = rt.substring("List<".length(), end).trim();
resp.containerType = "List";
}
} else if (rt.startsWith("Map")) {
int end = rt.lastIndexOf(">");
if (end > 0) {
resp.dataType = rt.substring("Map<".length(), end).split(",")[1].trim();
resp.baseType = rt.substring("Map<".length(), end).split(",")[1].trim();
resp.containerType = "Map";
}
} else if (rt.startsWith("Set")) {
int end = rt.lastIndexOf(">");
if (end > 0) {
resp.dataType = rt.substring("Set<".length(), end).trim();
resp.baseType = rt.substring("Set<".length(), end).trim();
resp.containerType = "Set";
}
}
}
}

if ( operation.returnType == null ) {
operation.returnType = "void";
// set vendorExtensions.x-java-is-response-void to true as returnType is set to "void"
operation.vendorExtensions.put("x-java-is-response-void", true);
// set vendorExtensions.x-java-is-response-void to true as returnType is set to "void"
operation.vendorExtensions.put("x-java-is-response-void", true);
} else if ( operation.returnType.startsWith("List") ) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
Expand All @@ -191,7 +217,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
if ( end > 0 ) {
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
operation.returnContainer = "Map";
}
}
} else if ( operation.returnType.startsWith("Set") ) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
Expand Down Expand Up @@ -242,5 +268,11 @@ public void setUseBeanValidation(boolean useBeanValidation) {
this.useBeanValidation = useBeanValidation;
}


/**
* Interface to set the data types for different Codegen objects.
*/
private interface DataTypeAssigner {
void setReturnType(String returnType);
void setReturnContainer(String returnContainer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class {{classname}} {
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},
{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
throws NotFoundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class {{classname}} {
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
return delegate.{{nickname}}({{#allParams}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/allParams}}securityContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface {{classname}} {
{{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}, response = {{{baseType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{/vendorExtensions.x-java-is-response-void}}){{#hasMore}},{{/hasMore}}{{/responses}} })
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}, response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}{{/vendorExtensions.x-java-is-response-void}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class {{classname}} {
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public Response {{nickname}}(
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
{{/allParams}}@Context SecurityContext securityContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class {{classname}} {
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
return Response.ok().entity("magic!").build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@

package io.swagger.client.model;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.UUID;
import javax.validation.constraints.*;
import javax.validation.Valid;

/**
* FormatTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AdditionalPropertiesClass mapProperty(Map<String, String> mapProperty) {

public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) {
if (this.mapProperty == null) {
this.mapProperty = new HashMap<String, String>();
this.mapProperty = new HashMap<>();
}
this.mapProperty.put(key, mapPropertyItem);
return this;
Expand All @@ -67,7 +67,7 @@ public AdditionalPropertiesClass mapOfMapProperty(Map<String, Map<String, String

public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map<String, String> mapOfMapPropertyItem) {
if (this.mapOfMapProperty == null) {
this.mapOfMapProperty = new HashMap<String, Map<String, String>>();
this.mapOfMapProperty = new HashMap<>();
}
this.mapOfMapProperty.put(key, mapOfMapPropertyItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ArrayOfArrayOfNumberOnly arrayArrayNumber(List<List<BigDecimal>> arrayArr

public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List<BigDecimal> arrayArrayNumberItem) {
if (this.arrayArrayNumber == null) {
this.arrayArrayNumber = new ArrayList<List<BigDecimal>>();
this.arrayArrayNumber = new ArrayList<>();
}
this.arrayArrayNumber.add(arrayArrayNumberItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ArrayOfNumberOnly arrayNumber(List<BigDecimal> arrayNumber) {

public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) {
if (this.arrayNumber == null) {
this.arrayNumber = new ArrayList<BigDecimal>();
this.arrayNumber = new ArrayList<>();
}
this.arrayNumber.add(arrayNumberItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ArrayTest arrayOfString(List<String> arrayOfString) {

public ArrayTest addArrayOfStringItem(String arrayOfStringItem) {
if (this.arrayOfString == null) {
this.arrayOfString = new ArrayList<String>();
this.arrayOfString = new ArrayList<>();
}
this.arrayOfString.add(arrayOfStringItem);
return this;
Expand All @@ -70,7 +70,7 @@ public ArrayTest arrayArrayOfInteger(List<List<Long>> arrayArrayOfInteger) {

public ArrayTest addArrayArrayOfIntegerItem(List<Long> arrayArrayOfIntegerItem) {
if (this.arrayArrayOfInteger == null) {
this.arrayArrayOfInteger = new ArrayList<List<Long>>();
this.arrayArrayOfInteger = new ArrayList<>();
}
this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem);
return this;
Expand All @@ -96,7 +96,7 @@ public ArrayTest arrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel)

public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = new ArrayList<List<ReadOnlyFirst>>();
this.arrayArrayOfModel = new ArrayList<>();
}
this.arrayArrayOfModel.add(arrayArrayOfModelItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public EnumArrays arrayEnum(List<ArrayEnumEnum> arrayEnum) {

public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
if (this.arrayEnum == null) {
this.arrayEnum = new ArrayList<ArrayEnumEnum>();
this.arrayEnum = new ArrayList<>();
}
this.arrayEnum.add(arrayEnumItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public MapTest mapMapOfString(Map<String, Map<String, String>> mapMapOfString) {

public MapTest putMapMapOfStringItem(String key, Map<String, String> mapMapOfStringItem) {
if (this.mapMapOfString == null) {
this.mapMapOfString = new HashMap<String, Map<String, String>>();
this.mapMapOfString = new HashMap<>();
}
this.mapMapOfString.put(key, mapMapOfStringItem);
return this;
Expand All @@ -102,7 +102,7 @@ public MapTest mapOfEnumString(Map<String, InnerEnum> mapOfEnumString) {

public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) {
if (this.mapOfEnumString == null) {
this.mapOfEnumString = new HashMap<String, InnerEnum>();
this.mapOfEnumString = new HashMap<>();
}
this.mapOfEnumString.put(key, mapOfEnumStringItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public MixedPropertiesAndAdditionalPropertiesClass map(Map<String, Animal> map)

public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) {
if (this.map == null) {
this.map = new HashMap<String, Animal>();
this.map = new HashMap<>();
}
this.map.put(key, mapItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Pet {
private String name = null;

@JsonProperty("photoUrls")
private List<String> photoUrls = new ArrayList<String>();
private List<String> photoUrls = new ArrayList<>();

@JsonProperty("tags")
private List<Tag> tags = null;
Expand Down Expand Up @@ -168,7 +168,7 @@ public Pet tags(List<Tag> tags) {

public Pet addTagsItem(Tag tagsItem) {
if (this.tags == null) {
this.tags = new ArrayList<Tag>();
this.tags = new ArrayList<>();
}
this.tags.add(tagsItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3-SNAPSHOT
2.3.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface StoreApi {
@Produces({ "application/json" })
@ApiOperation(value = "Returns pet inventories by status", tags={ "store", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") })
@ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") })
public Map<String, Integer> getInventory();

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public Order status(StatusEnum status) {
* Get complete
* @return complete
**/
public Boolean getComplete() {
public Boolean isComplete() {
return complete;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Cat declawed(Boolean declawed) {

@ApiModelProperty(value = "")
@JsonProperty("declawed")
public Boolean getDeclawed() {
public Boolean isDeclawed() {
return declawed;
}
public void setDeclawed(Boolean declawed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Order complete(Boolean complete) {

@ApiModelProperty(value = "")
@JsonProperty("complete")
public Boolean getComplete() {
public Boolean isComplete() {
return complete;
}
public void setComplete(Boolean complete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ public ResponseContext testEnumParameters(RequestContext request , List<String>
}
*/

/*
public ResponseContext testJsonFormData(RequestContext request , String param, String param2) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/

}

Loading