forked from loafle/openapi-generator-original
[General] Better code format (#11612)
* better code format in java tests * better code format in java client codegen * better code format in java model tests * better code format in abstract java codegen * better code format in codegen parameter, property * better code format in codegen response * better code format in codegen model * better code format in default generator * better code format in default codegen * update codegen model
This commit is contained in:
parent
52e3265c34
commit
878f6e5709
@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
@ -575,90 +576,114 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsModel() { return isModel; }
|
||||
public boolean getIsModel() {
|
||||
return isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDate() { return isDate; }
|
||||
public boolean getIsDate() {
|
||||
return isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDate(boolean isDate) {
|
||||
public void setIsDate(boolean isDate) {
|
||||
this.isDate = isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDateTime() { return isDateTime; }
|
||||
public boolean getIsDateTime() {
|
||||
return isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
this.isDateTime = isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsMap() { return isMap; }
|
||||
public boolean getIsMap() {
|
||||
return isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsMap(boolean isMap) {
|
||||
public void setIsMap(boolean isMap) {
|
||||
this.isMap = isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArray() { return isArray; }
|
||||
public boolean getIsArray() {
|
||||
return isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsArray(boolean isArray) {
|
||||
public void setIsArray(boolean isArray) {
|
||||
this.isArray = isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShort() { return isShort; }
|
||||
public boolean getIsShort() {
|
||||
return isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsShort(boolean isShort) {
|
||||
public void setIsShort(boolean isShort) {
|
||||
this.isShort = isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsBoolean() { return isBoolean; }
|
||||
|
||||
@Override
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
this.isBoolean= isBoolean;
|
||||
public boolean getIsBoolean() {
|
||||
return isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
this.isBoolean = isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
public boolean getIsUnboundedInteger() {
|
||||
return isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
public boolean getIsPrimitiveType() {
|
||||
return isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
public CodegenProperty getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasValidation() { return hasValidation; }
|
||||
public boolean getHasValidation() {
|
||||
return hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasValidation(boolean hasValidation) { this.hasValidation = hasValidation; }
|
||||
public void setHasValidation(boolean hasValidation) {
|
||||
this.hasValidation = hasValidation;
|
||||
}
|
||||
|
||||
public List<CodegenProperty> getReadOnlyVars() {
|
||||
return readOnlyVars;
|
||||
@ -785,7 +810,11 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() { return hasDiscriminatorWithNonEmptyMapping; };
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() {
|
||||
return hasDiscriminatorWithNonEmptyMapping;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
|
||||
@ -793,26 +822,32 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsString() { return isString; }
|
||||
public boolean getIsString() {
|
||||
return isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsString(boolean isString) {
|
||||
public void setIsString(boolean isString) {
|
||||
this.isString = isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNumber() { return isNumber; }
|
||||
public boolean getIsNumber() {
|
||||
return isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
this.isNumber = isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsAnyType() { return isAnyType; }
|
||||
public boolean getIsAnyType() {
|
||||
return isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@ -827,10 +862,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
|
||||
public boolean getHasMultipleTypes() {
|
||||
return hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) {
|
||||
this.hasMultipleTypes = hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -1043,7 +1082,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void addDiscriminatorMappedModelsImports(){
|
||||
public void addDiscriminatorMappedModelsImports() {
|
||||
if (discriminator == null || discriminator.getMappedModels() == null) {
|
||||
return;
|
||||
}
|
||||
@ -1065,6 +1104,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public boolean getHasItems() {
|
||||
return this.items != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove duplicated properties in all variable list
|
||||
*/
|
||||
|
@ -560,82 +560,102 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsModel() { return isModel; }
|
||||
public boolean getIsModel() {
|
||||
return isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDate() { return isDate; }
|
||||
public boolean getIsDate() {
|
||||
return isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDate(boolean isDate) {
|
||||
public void setIsDate(boolean isDate) {
|
||||
this.isDate = isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDateTime() { return isDateTime; }
|
||||
public boolean getIsDateTime() {
|
||||
return isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
this.isDateTime = isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsMap() { return isMap; }
|
||||
public boolean getIsMap() {
|
||||
return isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsMap(boolean isMap) {
|
||||
public void setIsMap(boolean isMap) {
|
||||
this.isMap = isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArray() { return isArray; }
|
||||
public boolean getIsArray() {
|
||||
return isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsArray(boolean isArray) {
|
||||
public void setIsArray(boolean isArray) {
|
||||
this.isArray = isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShort() { return isShort; }
|
||||
public boolean getIsShort() {
|
||||
return isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsShort(boolean isShort) {
|
||||
public void setIsShort(boolean isShort) {
|
||||
this.isShort = isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsBoolean() { return isBoolean; }
|
||||
public boolean getIsBoolean() {
|
||||
return isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
this.isBoolean = isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
|
||||
public boolean getIsUnboundedInteger() {
|
||||
return isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
public boolean getIsPrimitiveType() {
|
||||
return isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
public CodegenProperty getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
@ -670,10 +690,14 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasValidation() { return hasValidation; }
|
||||
public boolean getHasValidation() {
|
||||
return hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasValidation(boolean hasValidation) { this.hasValidation = hasValidation; }
|
||||
public void setHasValidation(boolean hasValidation) {
|
||||
this.hasValidation = hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAdditionalPropertiesIsAnyType() {
|
||||
@ -706,7 +730,11 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() { return hasDiscriminatorWithNonEmptyMapping; };
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() {
|
||||
return hasDiscriminatorWithNonEmptyMapping;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
|
||||
@ -714,26 +742,32 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsString() { return isString; }
|
||||
public boolean getIsString() {
|
||||
return isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsString(boolean isString) {
|
||||
public void setIsString(boolean isString) {
|
||||
this.isString = isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNumber() { return isNumber; }
|
||||
public boolean getIsNumber() {
|
||||
return isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
this.isNumber = isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsAnyType() { return isAnyType; }
|
||||
public boolean getIsAnyType() {
|
||||
return isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@ -748,14 +782,22 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
|
||||
public boolean getHasMultipleTypes() {
|
||||
return hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) {
|
||||
this.hasMultipleTypes = hasMultipleTypes;
|
||||
}
|
||||
|
||||
public CodegenProperty getSchema() {return schema; }
|
||||
public CodegenProperty getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public void setSchema(CodegenProperty schema) { this.schema = schema; }
|
||||
public void setSchema(CodegenProperty schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, CodegenMediaType> getContent() {
|
||||
return content;
|
||||
|
@ -465,82 +465,102 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
public CodegenProperty getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsModel() { return isModel; }
|
||||
public boolean getIsModel() {
|
||||
return isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDate() { return isDate; }
|
||||
public boolean getIsDate() {
|
||||
return isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDate(boolean isDate) {
|
||||
public void setIsDate(boolean isDate) {
|
||||
this.isDate = isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDateTime() { return isDateTime; }
|
||||
public boolean getIsDateTime() {
|
||||
return isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
this.isDateTime = isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsMap() { return isMap; }
|
||||
public boolean getIsMap() {
|
||||
return isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsMap(boolean isMap) {
|
||||
public void setIsMap(boolean isMap) {
|
||||
this.isMap = isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArray() { return isArray; }
|
||||
public boolean getIsArray() {
|
||||
return isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsArray(boolean isArray) {
|
||||
public void setIsArray(boolean isArray) {
|
||||
this.isArray = isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShort() { return isShort; }
|
||||
public boolean getIsShort() {
|
||||
return isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsShort(boolean isShort) {
|
||||
public void setIsShort(boolean isShort) {
|
||||
this.isShort = isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsBoolean() { return isBoolean; }
|
||||
public boolean getIsBoolean() {
|
||||
return isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
this.isBoolean = isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
|
||||
public boolean getIsUnboundedInteger() {
|
||||
return isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
public boolean getIsPrimitiveType() {
|
||||
return isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@ -743,10 +763,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasValidation() { return hasValidation; }
|
||||
public boolean getHasValidation() {
|
||||
return hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasValidation(boolean hasValidation) { this.hasValidation = hasValidation; }
|
||||
public void setHasValidation(boolean hasValidation) {
|
||||
this.hasValidation = hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAdditionalPropertiesIsAnyType() {
|
||||
@ -779,7 +803,11 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() { return hasDiscriminatorWithNonEmptyMapping; };
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() {
|
||||
return hasDiscriminatorWithNonEmptyMapping;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
|
||||
@ -791,34 +819,44 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsString() { return isString; }
|
||||
public boolean getIsString() {
|
||||
return isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsString(boolean isString) {
|
||||
public void setIsString(boolean isString) {
|
||||
this.isString = isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNumber() { return isNumber; }
|
||||
public boolean getIsNumber() {
|
||||
return isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
this.isNumber = isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsAnyType() { return isAnyType; }
|
||||
public boolean getIsAnyType() {
|
||||
return isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
|
||||
public boolean getHasMultipleTypes() {
|
||||
return hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) {
|
||||
this.hasMultipleTypes = hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -972,7 +1010,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
hasDiscriminatorWithNonEmptyMapping == that.hasDiscriminatorWithNonEmptyMapping &&
|
||||
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
|
||||
getHasVars() == that.getHasVars() &&
|
||||
getHasRequired() ==that.getHasRequired() &&
|
||||
getHasRequired() == that.getHasRequired() &&
|
||||
Objects.equals(composedSchemas, that.composedSchemas) &&
|
||||
Objects.equals(openApiType, that.openApiType) &&
|
||||
Objects.equals(baseName, that.baseName) &&
|
||||
|
@ -337,82 +337,102 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsModel() { return isModel; }
|
||||
public boolean getIsModel() {
|
||||
return isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArray() { return isArray; }
|
||||
public boolean getIsArray() {
|
||||
return isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsArray(boolean isArray) {
|
||||
public void setIsArray(boolean isArray) {
|
||||
this.isArray = isArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsShort() { return isShort; }
|
||||
public boolean getIsShort() {
|
||||
return isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsShort(boolean isShort) {
|
||||
public void setIsShort(boolean isShort) {
|
||||
this.isShort = isShort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsBoolean() { return isBoolean; }
|
||||
public boolean getIsBoolean() {
|
||||
return isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
public void setIsBoolean(boolean isBoolean) {
|
||||
this.isBoolean = isBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsUnboundedInteger() { return isUnboundedInteger; }
|
||||
public boolean getIsUnboundedInteger() {
|
||||
return isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
public void setIsUnboundedInteger(boolean isUnboundedInteger) {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return primitiveType; }
|
||||
public boolean getIsPrimitiveType() {
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.primitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDate() { return isDate; }
|
||||
public boolean getIsDate() {
|
||||
return isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDate(boolean isDate) {
|
||||
public void setIsDate(boolean isDate) {
|
||||
this.isDate = isDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsDateTime() { return isDateTime; }
|
||||
public boolean getIsDateTime() {
|
||||
return isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
public void setIsDateTime(boolean isDateTime) {
|
||||
this.isDateTime = isDateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsMap() { return isMap; }
|
||||
public boolean getIsMap() {
|
||||
return isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsMap(boolean isMap) {
|
||||
public void setIsMap(boolean isMap) {
|
||||
this.isMap = isMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
public CodegenProperty getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
public void setAdditionalProperties(CodegenProperty additionalProperties) {
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
@ -550,10 +570,14 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasValidation() { return hasValidation; }
|
||||
public boolean getHasValidation() {
|
||||
return hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasValidation(boolean hasValidation) { this.hasValidation = hasValidation; }
|
||||
public void setHasValidation(boolean hasValidation) {
|
||||
this.hasValidation = hasValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAdditionalPropertiesIsAnyType() {
|
||||
@ -576,7 +600,11 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() { return hasDiscriminatorWithNonEmptyMapping; };
|
||||
public boolean getHasDiscriminatorWithNonEmptyMapping() {
|
||||
return hasDiscriminatorWithNonEmptyMapping;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public void setHasDiscriminatorWithNonEmptyMapping(boolean hasDiscriminatorWithNonEmptyMapping) {
|
||||
@ -584,26 +612,32 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsString() { return isString; }
|
||||
public boolean getIsString() {
|
||||
return isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsString(boolean isString) {
|
||||
public void setIsString(boolean isString) {
|
||||
this.isString = isString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsNumber() { return isNumber; }
|
||||
public boolean getIsNumber() {
|
||||
return isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
public void setIsNumber(boolean isNumber) {
|
||||
this.isNumber = isNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsAnyType() { return isAnyType; }
|
||||
public boolean getIsAnyType() {
|
||||
return isAnyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
public void setIsAnyType(boolean isAnyType) {
|
||||
this.isAnyType = isAnyType;
|
||||
}
|
||||
|
||||
@ -618,10 +652,14 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasMultipleTypes() {return hasMultipleTypes; }
|
||||
public boolean getHasMultipleTypes() {
|
||||
return hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
|
||||
public void setHasMultipleTypes(boolean hasMultipleTypes) {
|
||||
this.hasMultipleTypes = hasMultipleTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseType() {
|
||||
|
@ -956,8 +956,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
.replaceAll("[\\t\\n\\r]", " ")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\""));
|
||||
@ -982,8 +982,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
.replaceAll("[\\t]", " ")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\""));
|
||||
@ -1536,12 +1536,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Returns the same content as [[toModelImport]] with key the fully-qualified Model name and value the initial input.
|
||||
* In case of union types this method has a key for each separate model and import.
|
||||
*
|
||||
* @param name the name of the "Model"
|
||||
* @return Map of fully-qualified models.
|
||||
*/
|
||||
@Override
|
||||
public Map<String,String> toModelImportMap(String name){
|
||||
return Collections.singletonMap(this.toModelImport(name),name);
|
||||
public Map<String, String> toModelImportMap(String name) {
|
||||
return Collections.singletonMap(this.toModelImport(name), name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1958,7 +1959,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
*
|
||||
* <p>
|
||||
* Return null if you do NOT want a default value.
|
||||
* Any non-null value will cause {{#defaultValue} check to pass.
|
||||
*
|
||||
@ -1976,7 +1977,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Return the default value of the parameter
|
||||
*
|
||||
* <p>
|
||||
* Return null if you do NOT want a default value.
|
||||
* Any non-null value will cause {{#defaultValue} check to pass.
|
||||
*
|
||||
@ -2401,6 +2402,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.name = name;
|
||||
this.schema = s;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Schema schema;
|
||||
|
||||
@ -2706,7 +2708,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.xmlNamespace = schema.getXml().getNamespace();
|
||||
m.xmlName = schema.getXml().getName();
|
||||
}
|
||||
if (!ModelUtils.isAnyType(schema) && !ModelUtils.isTypeObjectSchema(schema) && !ModelUtils.isArraySchema(schema) && schema.get$ref() == null && schema.getEnum() != null && !schema.getEnum().isEmpty()) {
|
||||
if (!ModelUtils.isAnyType(schema) && !ModelUtils.isTypeObjectSchema(schema) && !ModelUtils.isArraySchema(schema) && schema.get$ref() == null && schema.getEnum() != null && !schema.getEnum().isEmpty()) {
|
||||
// TODO remove the anyType check here in the future ANyType models can have enums defined
|
||||
m.isEnum = true;
|
||||
// comment out below as allowableValues is not set in post processing model enum
|
||||
@ -2791,7 +2793,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if (m.requiredVars != null && m.requiredVars.size() > 0){
|
||||
if (m.requiredVars != null && m.requiredVars.size() > 0) {
|
||||
m.setHasRequired(true);
|
||||
}
|
||||
|
||||
@ -2824,7 +2826,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return m;
|
||||
}
|
||||
|
||||
protected void setAddProps(Schema schema, IJsonSchemaValidationProperties property){
|
||||
protected void setAddProps(Schema schema, IJsonSchemaValidationProperties property) {
|
||||
if (schema.equals(new Schema())) {
|
||||
// if we are trying to set additionalProperties on an empty schema stop recursing
|
||||
return;
|
||||
@ -2839,7 +2841,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (schema.getAdditionalProperties() == null) {
|
||||
if (!disallowAdditionalPropertiesIfNotPresent) {
|
||||
isAdditionalPropertiesTrue = true;
|
||||
addPropProp = fromProperty("", new Schema());
|
||||
addPropProp = fromProperty("", new Schema());
|
||||
additionalPropertiesIsAnyType = true;
|
||||
}
|
||||
} else if (schema.getAdditionalProperties() instanceof Boolean) {
|
||||
@ -3018,7 +3020,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Integer hasDiscriminatorCnt = 0;
|
||||
Integer hasNullTypeCnt = 0;
|
||||
Set<String> discriminatorsPropNames = new HashSet<>();
|
||||
for (Schema anyOf : composedSchema.getAnyOf()) {
|
||||
for (Schema anyOf : composedSchema.getAnyOf()) {
|
||||
if (ModelUtils.isNullType(anyOf)) {
|
||||
// The null type does not have a discriminator. Skip.
|
||||
hasNullTypeCnt++;
|
||||
@ -3032,7 +3034,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
if (discriminatorsPropNames.size() > 1) {
|
||||
LOGGER.warn("The anyOf schemas have conflicting discriminator property names. " +
|
||||
"anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
|
||||
"anyOf schemas must have the same property name, but found " + String.join(", ", discriminatorsPropNames));
|
||||
}
|
||||
if (foundDisc != null && (hasDiscriminatorCnt + hasNullTypeCnt) == composedSchema.getAnyOf().size() && discriminatorsPropNames.size() == 1) {
|
||||
disc.setPropertyName(foundDisc.getPropertyName());
|
||||
@ -3216,7 +3218,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (MappedModel otherDescendant : otherDescendants) {
|
||||
// add only if the mapping names are not the same
|
||||
boolean matched = false;
|
||||
for (MappedModel uniqueDescendant: uniqueDescendants) {
|
||||
for (MappedModel uniqueDescendant : uniqueDescendants) {
|
||||
if (uniqueDescendant.getMappingName().equals(otherDescendant.getMappingName())) {
|
||||
matched = true;
|
||||
break;
|
||||
@ -3404,7 +3406,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Convert OAS Property object to Codegen Property object.
|
||||
*
|
||||
* <p>
|
||||
* The return value is cached. An internal cache is looked up to determine
|
||||
* if the CodegenProperty return value has already been instantiated for
|
||||
* the (String name, Schema p) arguments.
|
||||
@ -3635,7 +3637,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
protected void updatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty) {
|
||||
if (innerProperty == null) {
|
||||
if(LOGGER.isWarnEnabled()) {
|
||||
if (LOGGER.isWarnEnabled()) {
|
||||
LOGGER.warn("skipping invalid array property {}", Json.pretty(property));
|
||||
}
|
||||
return;
|
||||
@ -3670,7 +3672,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
protected void updatePropertyForMap(CodegenProperty property, CodegenProperty innerProperty) {
|
||||
if (innerProperty == null) {
|
||||
if(LOGGER.isWarnEnabled()) {
|
||||
if (LOGGER.isWarnEnabled()) {
|
||||
LOGGER.warn("skipping invalid map property {}", Json.pretty(property));
|
||||
}
|
||||
return;
|
||||
@ -3994,7 +3996,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Map<String, Header> headers = response.getHeaders();
|
||||
if (headers != null) {
|
||||
List<CodegenParameter> responseHeaders = new ArrayList<>();
|
||||
for (Entry<String, Header> entry: headers.entrySet()) {
|
||||
for (Entry<String, Header> entry : headers.entrySet()) {
|
||||
String headerName = entry.getKey();
|
||||
Header header = entry.getValue();
|
||||
CodegenParameter responseHeader = heeaderToCodegenParameter(header, headerName, imports, String.format(Locale.ROOT, "%sResponseParameter", r.code));
|
||||
@ -4025,7 +4027,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// check if any 4xx or 5xx reponse has an error response object defined
|
||||
if ((Boolean.TRUE.equals(r.is4xx) || Boolean.TRUE.equals(r.is5xx)) &&
|
||||
Boolean.FALSE.equals(r.primitiveType) && Boolean.FALSE.equals(r.simpleType)) {
|
||||
Boolean.FALSE.equals(r.primitiveType) && Boolean.FALSE.equals(r.simpleType)) {
|
||||
op.hasErrorResponseObject = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
@ -4386,7 +4388,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addVarsRequiredVarsAdditionalProps(responseSchema, r);
|
||||
} else if (ModelUtils.isAnyType(responseSchema)) {
|
||||
addVarsRequiredVarsAdditionalProps(responseSchema, r);
|
||||
} else if (!ModelUtils.isBooleanSchema(responseSchema)){
|
||||
} else if (!ModelUtils.isBooleanSchema(responseSchema)) {
|
||||
// referenced schemas
|
||||
LOGGER.debug("Property type is not primitive: {}", cp.dataType);
|
||||
}
|
||||
@ -4428,13 +4430,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
Stream.of(
|
||||
Pair.of("get", pi.getGet()),
|
||||
Pair.of("head", pi.getHead()),
|
||||
Pair.of("put", pi.getPut()),
|
||||
Pair.of("post", pi.getPost()),
|
||||
Pair.of("delete", pi.getDelete()),
|
||||
Pair.of("patch", pi.getPatch()),
|
||||
Pair.of("options", pi.getOptions()))
|
||||
Pair.of("get", pi.getGet()),
|
||||
Pair.of("head", pi.getHead()),
|
||||
Pair.of("put", pi.getPut()),
|
||||
Pair.of("post", pi.getPost()),
|
||||
Pair.of("delete", pi.getDelete()),
|
||||
Pair.of("patch", pi.getPatch()),
|
||||
Pair.of("options", pi.getOptions()))
|
||||
.filter(p -> p.getValue() != null)
|
||||
.forEach(p -> {
|
||||
String method = p.getKey();
|
||||
@ -4498,7 +4500,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema){
|
||||
protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema) {
|
||||
if (ModelUtils.isEmailSchema(parameterSchema)) {
|
||||
codegenParameter.isEmail = true;
|
||||
} else if (ModelUtils.isUUIDSchema(parameterSchema)) {
|
||||
@ -4752,7 +4754,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.items = fromProperty(codegenParameter.paramName, schema);
|
||||
// TODO Check why schema is actually null for a schema of type object defined inline
|
||||
// https://swagger.io/docs/specification/serialization/
|
||||
if(schema != null) {
|
||||
if (schema != null) {
|
||||
Map<String, Schema<?>> properties = schema.getProperties();
|
||||
codegenParameter.items.vars =
|
||||
properties.entrySet().stream()
|
||||
@ -4761,8 +4763,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.baseName = codegenParameter.baseName + "[" + entry.getKey() + "]";
|
||||
return property;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"No object schema found for deepObject parameter{} deepObject won't have specific properties",
|
||||
codegenParameter);
|
||||
@ -5082,15 +5083,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* of the 'additionalProperties' keyword. Some language generator use class inheritance
|
||||
* to implement additional properties. For example, in Java the generated model class
|
||||
* has 'extends HashMap' to represent the additional properties.
|
||||
*
|
||||
* <p>
|
||||
* TODO: it's not a good idea to use single class inheritance to implement
|
||||
* additionalProperties. That may work for non-composed schemas, but that does not
|
||||
* work for composed 'allOf' schemas. For example, in Java, if additionalProperties
|
||||
* is set to true (which it should be by default, per OAS spec), then the generated
|
||||
* code has extends HashMap. That wouldn't work for composed 'allOf' schemas.
|
||||
*
|
||||
* @param model the codegen representation of the OAS schema.
|
||||
* @param name the name of the model.
|
||||
* @param model the codegen representation of the OAS schema.
|
||||
* @param name the name of the model.
|
||||
* @param schema the input OAS schema.
|
||||
*/
|
||||
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
|
||||
@ -5175,7 +5176,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected void addVars(CodegenModel m, Map<String, Schema> properties, List<String> required,
|
||||
Map<String, Schema> allProperties, List<String> allRequired) {
|
||||
Map<String, Schema> allProperties, List<String> allRequired) {
|
||||
|
||||
m.hasRequired = false;
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
@ -5289,7 +5290,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* This includes a flat property type (e.g. property type: ReferencedModel)
|
||||
* as well as container type (property type: array of ReferencedModel's)
|
||||
*
|
||||
* @param model The codegen representation of the OAS schema.
|
||||
* @param model The codegen representation of the OAS schema.
|
||||
* @param property The codegen representation of the OAS schema's property.
|
||||
*/
|
||||
protected void addImportsForPropertyType(CodegenModel model, CodegenProperty property) {
|
||||
@ -5505,6 +5506,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* check if current active library equals to passed
|
||||
*
|
||||
* @param library - library to be compared with
|
||||
* @return {@code true} if passed library is active, {@code false} otherwise
|
||||
*/
|
||||
@ -6685,7 +6687,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
protected String toMediaTypeSchemaName(String contentType, String mediaTypeSchemaSuffix) {
|
||||
return "SchemaFor" + mediaTypeSchemaSuffix + toModelName(contentType);
|
||||
return "SchemaFor" + mediaTypeSchemaSuffix + toModelName(contentType);
|
||||
}
|
||||
|
||||
private CodegenParameter heeaderToCodegenParameter(Header header, String headerName, Set<String> imports, String mediaTypeSchemaSuffix) {
|
||||
@ -6718,18 +6720,18 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return null;
|
||||
}
|
||||
LinkedHashMap<String, CodegenMediaType> cmtContent = new LinkedHashMap<>();
|
||||
for (Entry<String, MediaType> contentEntry: content.entrySet()) {
|
||||
for (Entry<String, MediaType> contentEntry : content.entrySet()) {
|
||||
MediaType mt = contentEntry.getValue();
|
||||
LinkedHashMap<String, CodegenEncoding> ceMap = null;
|
||||
if (mt.getEncoding() != null ) {
|
||||
if (mt.getEncoding() != null) {
|
||||
ceMap = new LinkedHashMap<>();
|
||||
Map<String, Encoding> encMap = mt.getEncoding();
|
||||
for (Entry<String, Encoding> encodingEntry: encMap.entrySet()) {
|
||||
for (Entry<String, Encoding> encodingEntry : encMap.entrySet()) {
|
||||
Encoding enc = encodingEntry.getValue();
|
||||
List<CodegenParameter> headers = new ArrayList<>();
|
||||
if (enc.getHeaders() != null) {
|
||||
Map<String, Header> encHeaders = enc.getHeaders();
|
||||
for (Entry<String, Header> headerEntry: encHeaders.entrySet()) {
|
||||
for (Entry<String, Header> headerEntry : encHeaders.entrySet()) {
|
||||
String headerName = headerEntry.getKey();
|
||||
Header header = ModelUtils.getReferencedHeader(this.openAPI, headerEntry.getValue());
|
||||
CodegenParameter param = heeaderToCodegenParameter(header, headerName, imports, mediaTypeSchemaSuffix);
|
||||
@ -6852,7 +6854,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
|
||||
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property) {
|
||||
setAddProps(schema, property);
|
||||
if (!"object".equals(schema.getType())) {
|
||||
return;
|
||||
@ -6994,7 +6996,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenServerVariable.value = value;
|
||||
|
||||
if (enums != null && !enums.isEmpty() && !enums.contains(value)) {
|
||||
if(LOGGER.isWarnEnabled()) { // prevents calculating StringUtils.join when debug isn't enabled
|
||||
if (LOGGER.isWarnEnabled()) { // prevents calculating StringUtils.join when debug isn't enabled
|
||||
LOGGER.warn("Variable override of '{}' is not listed in the enum of allowed values ({}).", value, StringUtils.join(enums, ","));
|
||||
}
|
||||
}
|
||||
@ -7303,7 +7305,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Returns the additionalProperties Schema for the specified input schema.
|
||||
*
|
||||
* <p>
|
||||
* The additionalProperties keyword is used to control the handling of additional, undeclared
|
||||
* properties, that is, properties whose names are not listed in the properties keyword.
|
||||
* The additionalProperties keyword may be either a boolean or an object.
|
||||
@ -7314,7 +7316,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param schema the input schema that may or may not have the additionalProperties keyword.
|
||||
* @return the Schema of the additionalProperties. The null value is returned if no additional
|
||||
* properties are allowed.
|
||||
* properties are allowed.
|
||||
*/
|
||||
protected Schema getAdditionalProperties(Schema schema) {
|
||||
return ModelUtils.getAdditionalProperties(openAPI, schema);
|
||||
@ -7376,7 +7378,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
List<CodegenProperty> xOf = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (Schema xOfSchema: xOfCollection) {
|
||||
for (Schema xOfSchema : xOfCollection) {
|
||||
CodegenProperty cp = fromProperty(collectionName + "_" + i, xOfSchema);
|
||||
xOf.add(cp);
|
||||
i += 1;
|
||||
@ -7390,8 +7392,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.JAVA; }
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.JAVA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generatorLanguageVersion() { return null; };
|
||||
public String generatorLanguageVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class DefaultGenerator implements Generator {
|
||||
this.userDefinedTemplates = Collections.unmodifiableList(userFiles);
|
||||
}
|
||||
|
||||
TemplateManagerOptions templateManagerOptions = new TemplateManagerOptions(this.config.isEnableMinimalUpdate(),this.config.isSkipOverwrite());
|
||||
TemplateManagerOptions templateManagerOptions = new TemplateManagerOptions(this.config.isEnableMinimalUpdate(), this.config.isSkipOverwrite());
|
||||
|
||||
if (this.dryRun) {
|
||||
this.templateProcessor = new DryRunTemplateManager(templateManagerOptions);
|
||||
@ -459,7 +459,7 @@ public class DefaultGenerator implements Generator {
|
||||
// this use case arises when using interface schemas
|
||||
// generators may choose to make models for use case 2 + 3
|
||||
Schema refSchema = new Schema();
|
||||
refSchema.set$ref("#/components/schemas/"+name);
|
||||
refSchema.set$ref("#/components/schemas/" + name);
|
||||
Schema unaliasedSchema = config.unaliasSchema(refSchema, config.importMapping());
|
||||
if (unaliasedSchema.get$ref() == null) {
|
||||
LOGGER.info("Model {} not generated since it's a free-form object", name);
|
||||
@ -510,7 +510,7 @@ public class DefaultGenerator implements Generator {
|
||||
Map<String, Object> modelTemplate = (Map<String, Object>) modelList.get(0);
|
||||
if (modelTemplate != null && modelTemplate.containsKey("model")) {
|
||||
CodegenModel m = (CodegenModel) modelTemplate.get("model");
|
||||
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
|
||||
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
|
||||
// alias to number, string, enum, etc, which should not be generated as model
|
||||
// for PythonClientCodegen, all aliases are generated as models
|
||||
continue; // Don't create user-defined classes for aliases
|
||||
@ -692,7 +692,7 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
File of = new File(outputFolder);
|
||||
if (!of.isDirectory()) {
|
||||
if(!dryRun && !of.mkdirs()) {
|
||||
if (!dryRun && !of.mkdirs()) {
|
||||
once(LOGGER).debug("Output directory {} not created. It {}.", outputFolder, of.exists() ? "already exists." : "may not have appropriate permissions.");
|
||||
}
|
||||
}
|
||||
@ -806,14 +806,14 @@ public class DefaultGenerator implements Generator {
|
||||
* This adds a boolean and a collection for each authentication type to the map.
|
||||
* <p>
|
||||
* Examples:
|
||||
* <p>
|
||||
* <p>
|
||||
* boolean hasOAuthMethods
|
||||
* <p>
|
||||
* List<CodegenSecurity> oauthMethods
|
||||
*
|
||||
* @param bundle the map which the booleans and collections will be added
|
||||
*/
|
||||
void addAuthenticationSwitches(Map<String, Object> bundle){
|
||||
void addAuthenticationSwitches(Map<String, Object> bundle) {
|
||||
Map<String, SecurityScheme> securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null;
|
||||
List<CodegenSecurity> authMethods = config.fromSecurity(securitySchemeMap);
|
||||
if (authMethods != null && !authMethods.isEmpty()) {
|
||||
@ -894,7 +894,7 @@ public class DefaultGenerator implements Generator {
|
||||
Map<String, Object> bundle = buildSupportFileBundle(allOperations, allModels);
|
||||
generateSupportingFiles(files, bundle);
|
||||
|
||||
if(dryRun) {
|
||||
if (dryRun) {
|
||||
boolean verbose = Boolean.parseBoolean(GlobalSettings.getProperty("verbose"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@ -911,9 +911,9 @@ public class DefaultGenerator implements Generator {
|
||||
sb.append(System.lineSeparator());
|
||||
if (verbose) {
|
||||
sb.append(" ")
|
||||
.append(StringUtils.rightPad(status.getState().getDescription(), 20, "."))
|
||||
.append(" ").append(status.getReason())
|
||||
.append(System.lineSeparator());
|
||||
.append(StringUtils.rightPad(status.getState().getDescription(), 20, "."))
|
||||
.append(" ").append(status.getReason())
|
||||
.append(System.lineSeparator());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.debug("Unable to document dry run status for {}.", entry.getKey());
|
||||
@ -1031,7 +1031,7 @@ public class DefaultGenerator implements Generator {
|
||||
if (!absoluteTarget.startsWith(outDir)) {
|
||||
throw new RuntimeException(String.format(Locale.ROOT, "Target files must be generated within the output directory; absoluteTarget=%s outDir=%s", absoluteTarget, outDir));
|
||||
}
|
||||
return this.templateProcessor.write(templateData,templateName, target);
|
||||
return this.templateProcessor.write(templateData, templateName, target);
|
||||
} else {
|
||||
this.templateProcessor.skip(target.toPath(), String.format(Locale.ROOT, "Skipped by %s options supplied by user.", skippedByOption));
|
||||
return null;
|
||||
@ -1045,7 +1045,7 @@ public class DefaultGenerator implements Generator {
|
||||
public Map<String, List<CodegenOperation>> processPaths(Paths paths) {
|
||||
Map<String, List<CodegenOperation>> ops = new TreeMap<>();
|
||||
// when input file is not valid and doesn't contain any paths
|
||||
if(paths == null) {
|
||||
if (paths == null) {
|
||||
return ops;
|
||||
}
|
||||
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||
@ -1198,7 +1198,7 @@ public class DefaultGenerator implements Generator {
|
||||
allImports.addAll(op.imports);
|
||||
}
|
||||
|
||||
Map<String,String> mappings = getAllImportsMappings(allImports);
|
||||
Map<String, String> mappings = getAllImportsMappings(allImports);
|
||||
Set<Map<String, String>> imports = toImportsObjects(mappings);
|
||||
|
||||
//Some codegen implementations rely on a list interface for the imports
|
||||
@ -1215,16 +1215,17 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
/**
|
||||
* Transforms a set of imports to a map with key config.toModelImport(import) and value the import string.
|
||||
*
|
||||
* @param allImports - Set of imports
|
||||
* @return Map of fully qualified import path and initial import.
|
||||
*/
|
||||
private Map<String,String> getAllImportsMappings(Set<String> allImports){
|
||||
Map<String,String> result = new HashMap<>();
|
||||
allImports.forEach(nextImport->{
|
||||
private Map<String, String> getAllImportsMappings(Set<String> allImports) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
allImports.forEach(nextImport -> {
|
||||
String mapping = config.importMapping().get(nextImport);
|
||||
if(mapping!= null){
|
||||
result.put(mapping,nextImport);
|
||||
}else{
|
||||
if (mapping != null) {
|
||||
result.put(mapping, nextImport);
|
||||
} else {
|
||||
result.putAll(config.toModelImportMap(nextImport));
|
||||
}
|
||||
});
|
||||
@ -1238,23 +1239,23 @@ public class DefaultGenerator implements Generator {
|
||||
* @param mappedImports Map of fully qualified import and import
|
||||
* @return The set of unique imports
|
||||
*/
|
||||
private Set<Map<String,String>> toImportsObjects(Map<String,String> mappedImports){
|
||||
Set<Map<String, String>> result = new TreeSet<Map<String,String>>(
|
||||
(Comparator<Map<String, String>>) (o1, o2) -> {
|
||||
String s1 = o1.get("classname");
|
||||
String s2 = o2.get("classname");
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
private Set<Map<String, String>> toImportsObjects(Map<String, String> mappedImports) {
|
||||
Set<Map<String, String>> result = new TreeSet<Map<String, String>>(
|
||||
(Comparator<Map<String, String>>) (o1, o2) -> {
|
||||
String s1 = o1.get("classname");
|
||||
String s2 = o2.get("classname");
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
);
|
||||
|
||||
mappedImports.entrySet().forEach(mapping->{
|
||||
mappedImports.entrySet().forEach(mapping -> {
|
||||
Map<String, String> im = new LinkedHashMap<>();
|
||||
im.put("import", mapping.getKey());
|
||||
im.put("classname", mapping.getValue());
|
||||
result.add(im);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> processModels(CodegenConfig config, Map<String, Schema> definitions) {
|
||||
Map<String, Object> objs = new HashMap<>();
|
||||
|
@ -50,7 +50,7 @@ import java.util.stream.Stream;
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig,
|
||||
DocumentationProviderFeatures {
|
||||
DocumentationProviderFeatures {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class);
|
||||
private static final String ARTIFACT_VERSION_DEFAULT_VALUE = "1.0.0";
|
||||
@ -172,14 +172,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = Sets.newHashSet("String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
"byte[]"
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
"byte[]"
|
||||
);
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("set", "LinkedHashSet");
|
||||
@ -260,17 +260,17 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
if (null != defaultDocumentationProvider()) {
|
||||
CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER,
|
||||
"Select the OpenAPI documentation provider.")
|
||||
.defaultValue(defaultDocumentationProvider().toCliOptValue());
|
||||
"Select the OpenAPI documentation provider.")
|
||||
.defaultValue(defaultDocumentationProvider().toCliOptValue());
|
||||
supportedDocumentationProvider().forEach(dp ->
|
||||
documentationProviderCliOption.addEnum(dp.toCliOptValue(), dp.getDescription()));
|
||||
documentationProviderCliOption.addEnum(dp.toCliOptValue(), dp.getDescription()));
|
||||
cliOptions.add(documentationProviderCliOption);
|
||||
|
||||
CliOption annotationLibraryCliOption = new CliOption(ANNOTATION_LIBRARY,
|
||||
"Select the complementary documentation annotation library.")
|
||||
.defaultValue(defaultDocumentationProvider().getPreferredAnnotationLibrary().toCliOptValue());
|
||||
"Select the complementary documentation annotation library.")
|
||||
.defaultValue(defaultDocumentationProvider().getPreferredAnnotationLibrary().toCliOptValue());
|
||||
supportedAnnotationLibraries().forEach(al ->
|
||||
annotationLibraryCliOption.addEnum(al.toCliOptValue(), al.getDescription()));
|
||||
annotationLibraryCliOption.addEnum(al.toCliOptValue(), al.getDescription()));
|
||||
cliOptions.add(annotationLibraryCliOption);
|
||||
}
|
||||
}
|
||||
@ -279,34 +279,34 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (null != defaultDocumentationProvider()) {
|
||||
if (null != defaultDocumentationProvider()) {
|
||||
documentationProvider = DocumentationProvider.ofCliOption(
|
||||
(String)additionalProperties.getOrDefault(DOCUMENTATION_PROVIDER,
|
||||
defaultDocumentationProvider().toCliOptValue())
|
||||
(String) additionalProperties.getOrDefault(DOCUMENTATION_PROVIDER,
|
||||
defaultDocumentationProvider().toCliOptValue())
|
||||
);
|
||||
|
||||
if (! supportedDocumentationProvider().contains(documentationProvider)) {
|
||||
if (!supportedDocumentationProvider().contains(documentationProvider)) {
|
||||
String msg = String.format(Locale.ROOT,
|
||||
"The [%s] Documentation Provider is not supported by this generator",
|
||||
documentationProvider.toCliOptValue());
|
||||
"The [%s] Documentation Provider is not supported by this generator",
|
||||
documentationProvider.toCliOptValue());
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
annotationLibrary = AnnotationLibrary.ofCliOption(
|
||||
(String) additionalProperties.getOrDefault(ANNOTATION_LIBRARY,
|
||||
documentationProvider.getPreferredAnnotationLibrary().toCliOptValue())
|
||||
(String) additionalProperties.getOrDefault(ANNOTATION_LIBRARY,
|
||||
documentationProvider.getPreferredAnnotationLibrary().toCliOptValue())
|
||||
);
|
||||
|
||||
if (! supportedAnnotationLibraries().contains(annotationLibrary)) {
|
||||
if (!supportedAnnotationLibraries().contains(annotationLibrary)) {
|
||||
String msg = String.format(Locale.ROOT, "The Annotation Library [%s] is not supported by this generator",
|
||||
annotationLibrary.toCliOptValue());
|
||||
annotationLibrary.toCliOptValue());
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
if (! documentationProvider.supportedAnnotationLibraries().contains(annotationLibrary)) {
|
||||
if (!documentationProvider.supportedAnnotationLibraries().contains(annotationLibrary)) {
|
||||
String msg = String.format(Locale.ROOT,
|
||||
"The [%s] documentation provider does not support [%s] as complementary annotation library",
|
||||
documentationProvider.toCliOptValue(), annotationLibrary.toCliOptValue());
|
||||
"The [%s] documentation provider does not support [%s] as complementary annotation library",
|
||||
documentationProvider.toCliOptValue(), annotationLibrary.toCliOptValue());
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
|
||||
@ -946,8 +946,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
} else if (schema.getDefault() instanceof java.time.OffsetDateTime) {
|
||||
if ("java8".equals(getDateLibrary())) {
|
||||
return String.format(Locale.ROOT, "OffsetDateTime.parse(\"%s\", %s)",
|
||||
((java.time.OffsetDateTime) schema.getDefault()).atZoneSameInstant(ZoneId.systemDefault()),
|
||||
"java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.withZone(java.time.ZoneId.systemDefault())");
|
||||
((java.time.OffsetDateTime) schema.getDefault()).atZoneSameInstant(ZoneId.systemDefault()),
|
||||
"java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.withZone(java.time.ZoneId.systemDefault())");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -984,7 +984,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (defaultValue == null) {
|
||||
return null;
|
||||
}
|
||||
if (defaultValue instanceof Date) {
|
||||
if (defaultValue instanceof Date) {
|
||||
Date date = (Date) schema.getDefault();
|
||||
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
return localDate.toString();
|
||||
@ -1403,10 +1403,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
// - ENUM_A
|
||||
// - ENUM_B
|
||||
Stream.concat(
|
||||
Stream.of(openAPI.getComponents().getSchemas()),
|
||||
openAPI.getComponents().getSchemas().values().stream()
|
||||
.filter(schema -> schema.getProperties() != null)
|
||||
.map(Schema::getProperties))
|
||||
Stream.of(openAPI.getComponents().getSchemas()),
|
||||
openAPI.getComponents().getSchemas().values().stream()
|
||||
.filter(schema -> schema.getProperties() != null)
|
||||
.map(Schema::getProperties))
|
||||
.forEach(schemas -> schemas.replaceAll(
|
||||
(name, s) -> Stream.of(s)
|
||||
.filter(schema -> schema instanceof ComposedSchema)
|
||||
|
@ -63,9 +63,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles";
|
||||
public static final String DYNAMIC_OPERATIONS = "dynamicOperations";
|
||||
public static final String SUPPORT_STREAMING = "supportStreaming";
|
||||
public static final String GRADLE_PROPERTIES= "gradleProperties";
|
||||
public static final String ERROR_OBJECT_TYPE= "errorObjectType";
|
||||
public static final String ERROR_OBJECT_SUBTYPE= "errorObjectSubtype";
|
||||
public static final String GRADLE_PROPERTIES = "gradleProperties";
|
||||
public static final String ERROR_OBJECT_TYPE = "errorObjectType";
|
||||
public static final String ERROR_OBJECT_SUBTYPE = "errorObjectSubtype";
|
||||
|
||||
public static final String MICROPROFILE_DEFAULT = "default";
|
||||
public static final String MICROPROFILE_KUMULUZEE = "kumuluzee";
|
||||
@ -329,7 +329,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.put(ERROR_OBJECT_TYPE, errorObjectType);
|
||||
|
||||
if (additionalProperties.containsKey(ERROR_OBJECT_SUBTYPE)) {
|
||||
this.setErrorObjectSubtype((List<String>)additionalProperties.get(ERROR_OBJECT_SUBTYPE));
|
||||
this.setErrorObjectSubtype((List<String>) additionalProperties.get(ERROR_OBJECT_SUBTYPE));
|
||||
}
|
||||
additionalProperties.put(ERROR_OBJECT_SUBTYPE, errorObjectSubtype);
|
||||
|
||||
@ -979,15 +979,15 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
public void setGradleProperties(final String gradleProperties) {
|
||||
this.gradleProperties= gradleProperties;
|
||||
this.gradleProperties = gradleProperties;
|
||||
}
|
||||
|
||||
public void setErrorObjectType(final String errorObjectType) {
|
||||
this.errorObjectType= errorObjectType;
|
||||
this.errorObjectType = errorObjectType;
|
||||
}
|
||||
|
||||
public void setErrorObjectSubtype(final List<String> errorObjectSubtype) {
|
||||
this.errorObjectSubtype= errorObjectSubtype;
|
||||
this.errorObjectSubtype = errorObjectSubtype;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,10 +20,12 @@ package org.openapitools.codegen.java;
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
@ -214,7 +216,7 @@ public class AbstractJavaCodegenTest {
|
||||
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@Foo;@Bar");
|
||||
|
||||
|
||||
codegen.processOpts();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
@ -229,14 +231,14 @@ public class AbstractJavaCodegenTest {
|
||||
Collections.sort(sortedAdditionalModelTypeAnnotations);
|
||||
Assert.assertEquals(sortedCodegenAdditionalModelTypeAnnotations, sortedAdditionalModelTypeAnnotations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAdditionalModelTypeAnnotationsNewLineLinux() throws Exception {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@Foo\n@Bar");
|
||||
|
||||
|
||||
codegen.processOpts();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
@ -251,14 +253,14 @@ public class AbstractJavaCodegenTest {
|
||||
Collections.sort(sortedAdditionalModelTypeAnnotations);
|
||||
Assert.assertEquals(sortedCodegenAdditionalModelTypeAnnotations, sortedAdditionalModelTypeAnnotations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAdditionalModelTypeAnnotationsNewLineWindows() throws Exception {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@Foo\r\n@Bar");
|
||||
|
||||
|
||||
codegen.processOpts();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
@ -273,17 +275,17 @@ public class AbstractJavaCodegenTest {
|
||||
Collections.sort(sortedAdditionalModelTypeAnnotations);
|
||||
Assert.assertEquals(sortedCodegenAdditionalModelTypeAnnotations, sortedAdditionalModelTypeAnnotations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAdditionalModelTypeAnnotationsMixed() throws Exception {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, " \t @Foo;\r\n@Bar ;\n @Foobar ");
|
||||
|
||||
|
||||
codegen.processOpts();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
|
||||
final List<String> additionalModelTypeAnnotations = new ArrayList<String>();
|
||||
additionalModelTypeAnnotations.add("@Foo");
|
||||
additionalModelTypeAnnotations.add("@Bar");
|
||||
@ -296,17 +298,17 @@ public class AbstractJavaCodegenTest {
|
||||
Collections.sort(sortedAdditionalModelTypeAnnotations);
|
||||
Assert.assertEquals(sortedCodegenAdditionalModelTypeAnnotations, sortedAdditionalModelTypeAnnotations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAdditionalModelTypeAnnotationsNoDuplicate() throws Exception {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@Foo;@Bar;@Foo");
|
||||
|
||||
|
||||
codegen.processOpts();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
|
||||
final List<String> additionalModelTypeAnnotations = new ArrayList<String>();
|
||||
additionalModelTypeAnnotations.add("@Foo");
|
||||
additionalModelTypeAnnotations.add("@Bar");
|
||||
@ -318,7 +320,7 @@ public class AbstractJavaCodegenTest {
|
||||
Collections.sort(sortedAdditionalModelTypeAnnotations);
|
||||
Assert.assertEquals(sortedCodegenAdditionalModelTypeAnnotations, sortedAdditionalModelTypeAnnotations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void toEnumValue() {
|
||||
final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
@ -529,7 +531,6 @@ public class AbstractJavaCodegenTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test(description = "tests if default version with snapshot is used when setArtifactVersion is used")
|
||||
public void snapshotVersionAlreadySnapshotTest() {
|
||||
final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
@ -543,6 +544,7 @@ public class AbstractJavaCodegenTest {
|
||||
|
||||
Assert.assertEquals(codegen.getArtifactVersion(), "4.1.2-SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDefaultValueDateTimeLegacyTest() {
|
||||
final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
|
||||
@ -551,7 +553,7 @@ public class AbstractJavaCodegenTest {
|
||||
|
||||
// Test default value for date format
|
||||
DateSchema dateSchema = new DateSchema();
|
||||
LocalDate defaultLocalDate = LocalDate.of(2019,2,15);
|
||||
LocalDate defaultLocalDate = LocalDate.of(2019, 2, 15);
|
||||
Date date = Date.from(defaultLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
dateSchema.setDefault(date);
|
||||
defaultValue = codegen.toDefaultValue(dateSchema);
|
||||
@ -607,7 +609,7 @@ public class AbstractJavaCodegenTest {
|
||||
|
||||
// Test default value for date format
|
||||
DateSchema dateSchema = new DateSchema();
|
||||
LocalDate defaultLocalDate = LocalDate.of(2019,2,15);
|
||||
LocalDate defaultLocalDate = LocalDate.of(2019, 2, 15);
|
||||
Date date = Date.from(defaultLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
dateSchema.setDefault(date);
|
||||
defaultValue = codegen.toDefaultValue(dateSchema);
|
||||
|
@ -107,11 +107,11 @@ public class JavaModelTest {
|
||||
@Test(description = "convert a model with list property")
|
||||
public void listPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new JavaClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
@ -138,12 +138,12 @@ public class JavaModelTest {
|
||||
@Test(description = "convert a model with set property")
|
||||
public void setPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema())
|
||||
.uniqueItems(true))
|
||||
.addRequiredItem("id");
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema())
|
||||
.uniqueItems(true))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new JavaClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
@ -406,8 +406,8 @@ public class JavaModelTest {
|
||||
Assert.assertTrue(property.isContainer);
|
||||
|
||||
final CodegenProperty itemsProperty = property.items;
|
||||
Assert.assertEquals(itemsProperty.baseName,"child");
|
||||
Assert.assertEquals(itemsProperty.name,"child");
|
||||
Assert.assertEquals(itemsProperty.baseName, "child");
|
||||
Assert.assertEquals(itemsProperty.name, "child");
|
||||
}
|
||||
|
||||
@Test(description = "convert an array model")
|
||||
@ -745,7 +745,7 @@ public class JavaModelTest {
|
||||
|
||||
@DataProvider(name = "modelNames")
|
||||
public static Object[][] primeNumbers() {
|
||||
return new Object[][] {
|
||||
return new Object[][]{
|
||||
{"sample", "Sample"},
|
||||
{"sample_name", "SampleName"},
|
||||
{"sample__name", "SampleName"},
|
||||
@ -771,7 +771,7 @@ public class JavaModelTest {
|
||||
|
||||
@DataProvider(name = "classProperties")
|
||||
public static Object[][] classProperties() {
|
||||
return new Object[][] {
|
||||
return new Object[][]{
|
||||
{"class", "getPropertyClass", "setPropertyClass", "propertyClass"},
|
||||
{"_class", "getPropertyClass", "setPropertyClass", "propertyClass"},
|
||||
{"__class", "getPropertyClass", "setPropertyClass", "propertyClass"}
|
||||
@ -1178,7 +1178,7 @@ public class JavaModelTest {
|
||||
@Test(description = "convert an array schema in an ApiResponse")
|
||||
public void arraySchemaTestInOperationResponse() {
|
||||
final Schema testSchema = new ArraySchema()
|
||||
.items(new Schema<>().$ref("#/components/schemas/Pet"));
|
||||
.items(new Schema<>().$ref("#/components/schemas/Pet"));
|
||||
Operation operation = new Operation().responses(
|
||||
new ApiResponses().addApiResponse("200", new ApiResponse()
|
||||
.description("Ok response")
|
||||
|
Loading…
x
Reference in New Issue
Block a user