Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/collection of valid mapped schemas #632

Merged
merged 12 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -214,11 +214,11 @@ public BoatSpringCodeGen() {
public CodegenParameter fromParameter(Parameter parameter, Set<String> imports) {
CodegenParameter codegenParameter = super.fromParameter(parameter, imports);
if (!isListOrSet(codegenParameter)) {
return codegenParameter;
return new BoatSpringCodegenParameter(codegenParameter);
} else {
codegenParameter.datatypeWithEnum = replaceBeanValidationCollectionType(codegenParameter.items, codegenParameter.datatypeWithEnum);
codegenParameter.dataType = replaceBeanValidationCollectionType(codegenParameter.items, codegenParameter.dataType);
return codegenParameter;
return new BoatSpringCodegenParameter(codegenParameter);
}
}

Expand All @@ -229,11 +229,11 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
public CodegenProperty fromProperty(String name, Schema p, boolean required, boolean schemaIsFromAdditionalProperties) {
CodegenProperty codegenProperty = super.fromProperty(name, p, required, schemaIsFromAdditionalProperties);
if (!isListOrSet(codegenProperty)) {
return codegenProperty;
return new BoatSpringCodegenProperty(codegenProperty);
} else {
codegenProperty.datatypeWithEnum = replaceBeanValidationCollectionType(codegenProperty.items, codegenProperty.datatypeWithEnum);
codegenProperty.dataType = replaceBeanValidationCollectionType(codegenProperty.items, codegenProperty.dataType);
return codegenProperty;
return new BoatSpringCodegenProperty(codegenProperty);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package com.backbase.oss.codegen.java;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenParameter;

import java.util.Objects;

public class BoatSpringCodegenParameter extends CodegenParameter {

@Getter
public String packageName;
@Getter
public String simpleName;

public BoatSpringCodegenParameter(CodegenParameter codegenParameter) {
super();
super.isFormParam = codegenParameter.isFormParam;
super.isQueryParam = codegenParameter.isQueryParam;
super.isPathParam = codegenParameter.isPathParam;
super.isHeaderParam = codegenParameter.isHeaderParam;
super.isCookieParam = codegenParameter.isCookieParam;
super.isBodyParam = codegenParameter.isBodyParam;
super.isContainer = codegenParameter.isContainer;
super.isCollectionFormatMulti = codegenParameter.isCollectionFormatMulti;
super.isPrimitiveType = codegenParameter.isPrimitiveType;
super.isModel = codegenParameter.isModel;
super.isExplode = codegenParameter.isExplode;
super.isDeepObject = codegenParameter.isDeepObject;
super.isAllowEmptyValue = codegenParameter.isAllowEmptyValue;
super.baseName = codegenParameter.baseName;
super.paramName = codegenParameter.paramName;
super.dataType = codegenParameter.dataType;
super.datatypeWithEnum = codegenParameter.datatypeWithEnum;
super.dataFormat = codegenParameter.dataFormat;
super.contentType = codegenParameter.contentType;
super.collectionFormat = codegenParameter.collectionFormat;
super.description = codegenParameter.description;
super.unescapedDescription = codegenParameter.unescapedDescription;
super.baseType = codegenParameter.baseType;
super.defaultValue = codegenParameter.defaultValue;
super.enumDefaultValue = codegenParameter.enumDefaultValue;
super.enumName = codegenParameter.enumName;
super.style = codegenParameter.style;
super.nameInLowerCase = codegenParameter.nameInLowerCase;
super.example = codegenParameter.example;
super.jsonSchema = codegenParameter.jsonSchema;
super.isString = codegenParameter.isString;
super.isNumeric = codegenParameter.isNumeric;
super.isInteger = codegenParameter.isInteger;
super.isLong = codegenParameter.isLong;
super.isNumber = codegenParameter.isNumber;
super.isFloat = codegenParameter.isFloat;
super.isDouble = codegenParameter.isDouble;
super.isDecimal = codegenParameter.isDecimal;
super.isByteArray = codegenParameter.isByteArray;
super.isBinary = codegenParameter.isBinary;
super.isBoolean = codegenParameter.isBoolean;
super.isDate = codegenParameter.isDate;
super.isDateTime = codegenParameter.isDateTime;
super.isUuid = codegenParameter.isUuid;
super.isUri = codegenParameter.isUri;
super.isEmail = codegenParameter.isEmail;
super.isPassword = codegenParameter.isPassword;
super.isFreeFormObject = codegenParameter.isFreeFormObject;
super.isAnyType = codegenParameter.isAnyType;
super.isShort = codegenParameter.isShort;
super.isUnboundedInteger = codegenParameter.isUnboundedInteger;
super.isArray = codegenParameter.isArray;
super.isMap = codegenParameter.isMap;
super.isFile = codegenParameter.isFile;
super.isEnum = codegenParameter.isEnum;
super.isEnumRef = codegenParameter.isEnumRef;
super._enum = codegenParameter._enum;
super.allowableValues = codegenParameter.allowableValues;
super.items = codegenParameter.items;
super.additionalProperties = codegenParameter.additionalProperties;
super.vars = codegenParameter.vars;
super.requiredVars = codegenParameter.requiredVars;
super.mostInnerItems = codegenParameter.mostInnerItems;
super.vendorExtensions = codegenParameter.vendorExtensions;
super.hasValidation = codegenParameter.hasValidation;
super.isNullable = codegenParameter.isNullable;
super.isDeprecated = codegenParameter.isDeprecated;
super.required = codegenParameter.required;
super.maximum = codegenParameter.maximum;
super.exclusiveMaximum = codegenParameter.exclusiveMaximum;
super.minimum = codegenParameter.minimum;
super.exclusiveMinimum = codegenParameter.exclusiveMinimum;
super.maxLength = codegenParameter.maxLength;
super.minLength = codegenParameter.minLength;
super.pattern = codegenParameter.pattern;
super.maxItems = codegenParameter.maxItems;
super.minItems = codegenParameter.minItems;
super.uniqueItems = codegenParameter.uniqueItems;
super.multipleOf = codegenParameter.multipleOf;
super.isNull = codegenParameter.isNull;
super.isVoid = codegenParameter.isVoid;
super.setAdditionalPropertiesIsAnyType(codegenParameter.getAdditionalPropertiesIsAnyType());
super.setHasVars(codegenParameter.getHasVars());
super.setSchema(codegenParameter.getSchema());
super.setUniqueItemsBoolean(codegenParameter.getUniqueItemsBoolean());
super.setMaxProperties(codegenParameter.getMaxProperties());
super.setMinProperties(codegenParameter.getMinProperties());
super.setHasRequired(codegenParameter.getHasRequired());
super.setHasDiscriminatorWithNonEmptyMapping(codegenParameter.getHasDiscriminatorWithNonEmptyMapping());
super.setComposedSchemas(codegenParameter.getComposedSchemas());
super.setHasMultipleTypes(codegenParameter.getHasMultipleTypes());
super.setContent(codegenParameter.getContent());
super.setRequiredVarsMap(codegenParameter.getRequiredVarsMap());
super.setRef(codegenParameter.getRef());
super.setAdditionalProperties(codegenParameter.getAdditionalProperties());
if (StringUtils.contains(dataType, ".")) {
packageName = StringUtils.substringBeforeLast(dataType, ".") + ".";
jjjasper marked this conversation as resolved.
Show resolved Hide resolved
simpleName = StringUtils.substringAfterLast(dataType, ".");
} else {
packageName = "";
simpleName = dataType;
}
}

@Override
public String toString() {
return new StringBuilder(super.toString())
.append("packageName:'").append(packageName)
.append("',simpleName:'").append(simpleName)
.append("'").toString();
}

@Override
public boolean equals(Object o) {
return super.equals(o) &&
o instanceof BoatSpringCodegenParameter &&
Objects.equals(((BoatSpringCodegenParameter)o).packageName, this.packageName) &&
Objects.equals(((BoatSpringCodegenParameter)o).simpleName, this.simpleName);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), packageName, simpleName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package com.backbase.oss.codegen.java;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenProperty;

import java.util.Objects;

public class BoatSpringCodegenProperty extends CodegenProperty {

@Getter
public String packageName;
@Getter
public String simpleName;

public BoatSpringCodegenProperty(CodegenProperty codegenProperty) {
super();
super.openApiType = codegenProperty.openApiType;
super.baseName = codegenProperty.baseName;
super.complexType = codegenProperty.complexType;
super.getter = codegenProperty.getter;
super.setter = codegenProperty.setter;
super.description = codegenProperty.description;
super.dataType = codegenProperty.dataType;
super.datatypeWithEnum = codegenProperty.datatypeWithEnum;
super.dataFormat = codegenProperty.dataFormat;
super.name = codegenProperty.name;
super.min = codegenProperty.min;
super.max = codegenProperty.max;
super.defaultValue = codegenProperty.defaultValue;
super.defaultValueWithParam = codegenProperty.defaultValueWithParam;
super.baseType = codegenProperty.baseType;
super.containerType = codegenProperty.containerType;
super.title = codegenProperty.title;
super.unescapedDescription = codegenProperty.unescapedDescription;
super.maxLength = codegenProperty.maxLength;
super.minLength = codegenProperty.minLength;
super.pattern = codegenProperty.pattern;
super.example = codegenProperty.example;
super.jsonSchema = codegenProperty.jsonSchema;
super.minimum = codegenProperty.minimum;
super.maximum = codegenProperty.maximum;
super.multipleOf = codegenProperty.multipleOf;
super.exclusiveMinimum = codegenProperty.exclusiveMinimum;
super.exclusiveMaximum = codegenProperty.exclusiveMaximum;
super.required = codegenProperty.required;
super.deprecated = codegenProperty.deprecated;
super.hasMoreNonReadOnly = codegenProperty.hasMoreNonReadOnly;
super.isPrimitiveType = codegenProperty.isPrimitiveType;
super.isModel = codegenProperty.isModel;
super.isContainer = codegenProperty.isContainer;
super.isString = codegenProperty.isString;
super.isNumeric = codegenProperty.isNumeric;
super.isInteger = codegenProperty.isInteger;
super.isShort = codegenProperty.isShort;
super.isLong = codegenProperty.isLong;
super.isUnboundedInteger = codegenProperty.isUnboundedInteger;
super.isNumber = codegenProperty.isNumber;
super.isFloat = codegenProperty.isFloat;
super.isDouble = codegenProperty.isDouble;
super.isDecimal = codegenProperty.isDecimal;
super.isByteArray = codegenProperty.isByteArray;
super.isBinary = codegenProperty.isBinary;
super.isFile = codegenProperty.isFile;
super.isBoolean = codegenProperty.isBoolean;
super.isDate = codegenProperty.isDate;
super.isDateTime = codegenProperty.isDateTime;
super.isUuid = codegenProperty.isUuid;
super.isUri = codegenProperty.isUri;
super.isEmail = codegenProperty.isEmail;
super.isPassword = codegenProperty.isPassword;
super.isNull = codegenProperty.isNull;
super.isVoid = codegenProperty.isVoid;
super.isFreeFormObject = codegenProperty.isFreeFormObject;
super.isAnyType = codegenProperty.isAnyType;
super.isArray = codegenProperty.isArray;
super.isMap = codegenProperty.isMap;
super.isEnum = codegenProperty.isEnum;
super.isInnerEnum = codegenProperty.isInnerEnum;
super.isEnumRef = codegenProperty.isEnumRef;
super.isReadOnly = codegenProperty.isReadOnly;
super.isWriteOnly = codegenProperty.isWriteOnly;
super.isNullable = codegenProperty.isNullable;
super.isSelfReference = codegenProperty.isSelfReference;
super.isCircularReference = codegenProperty.isCircularReference;
super.isDiscriminator = codegenProperty.isDiscriminator;
super.isNew = codegenProperty.isNew;
super.isOverridden = codegenProperty.isOverridden;
super._enum = codegenProperty._enum;
super.allowableValues = codegenProperty.allowableValues;
super.items = codegenProperty.items;
super.additionalProperties = codegenProperty.additionalProperties;
super.vars = codegenProperty.vars;
super.requiredVars = codegenProperty.requiredVars;
super.mostInnerItems = codegenProperty.mostInnerItems;
super.vendorExtensions = codegenProperty.vendorExtensions;
super.hasValidation = codegenProperty.hasValidation;
super.isInherited = codegenProperty.isInherited;
super.discriminatorValue = codegenProperty.discriminatorValue;
super.nameInLowerCase = codegenProperty.nameInLowerCase;
super.nameInCamelCase = codegenProperty.nameInCamelCase;
super.nameInSnakeCase = codegenProperty.nameInSnakeCase;
super.enumName = codegenProperty.enumName;
super.maxItems = codegenProperty.maxItems;
super.minItems = codegenProperty.minItems;
super.isXmlAttribute = codegenProperty.isXmlAttribute = false;
super.xmlPrefix = codegenProperty.xmlPrefix;
super.xmlName = codegenProperty.xmlName;
super.xmlNamespace = codegenProperty.xmlNamespace;
super.isXmlWrapped = codegenProperty.isXmlWrapped = false;
super.setAdditionalPropertiesIsAnyType ( codegenProperty.getAdditionalPropertiesIsAnyType());
super.setHasVars ( codegenProperty.getHasVars());
super.setHasRequired ( codegenProperty.getHasRequired());
super.setHasDiscriminatorWithNonEmptyMapping (codegenProperty.getHasDiscriminatorWithNonEmptyMapping());
super.setComposedSchemas ( codegenProperty.getComposedSchemas ());
super.setHasMultipleTypes ( codegenProperty.getHasMultipleTypes());
super.setRequiredVarsMap ( codegenProperty.getRequiredVarsMap());
super.setRef ( codegenProperty.getRef());
super.setSchemaIsFromAdditionalProperties ( codegenProperty.getSchemaIsFromAdditionalProperties());
super.setIsBooleanSchemaTrue ( codegenProperty.getIsBooleanSchemaTrue());
super.setIsBooleanSchemaFalse ( codegenProperty.getIsBooleanSchemaFalse());
super.setFormat ( codegenProperty.getFormat());
super.setDependentRequired ( codegenProperty.getDependentRequired());
super.setContains ( codegenProperty.getContains());
super.setMaxProperties ( codegenProperty.getMaxProperties());
super.setMinProperties ( codegenProperty.getMinProperties());
super.setUniqueItems ( codegenProperty.getUniqueItems());
super.setUniqueItemsBoolean ( codegenProperty.getUniqueItemsBoolean());
if (StringUtils.contains(complexType, ".")) {
packageName = StringUtils.substringBeforeLast(complexType, ".") + ".";
simpleName = StringUtils.substringAfterLast(complexType, ".");
} else {
packageName = "";
simpleName = datatypeWithEnum;
}
}
@Override
public String toString() {
return new StringBuilder(super.toString())
.append("packageName:'").append(packageName)
.append("',simpleName:'").append(simpleName)
.append("'").toString();
}

@Override
public boolean equals(Object o) {
return super.equals(o) &&
o instanceof BoatSpringCodegenProperty &&
Objects.equals(((BoatSpringCodegenProperty)o).packageName, this.packageName) &&
Objects.equals(((BoatSpringCodegenProperty)o).simpleName, this.simpleName);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), packageName, simpleName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
{{>beanValidationCore}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
@Valid
{{packageName}}@Valid
{{/isPrimitiveType}}
{{/items}}
{{/useBeanValidation}}
{{^useBeanValidation}}
{{items.packageName}}
{{/useBeanValidation}}
{{! apply collection item type }}
{{{items.datatypeWithEnum}}}>
{{items.simpleName}}>
{{#openApiNullable}}
{{#isNullable}}>{{/isNullable}}
{{/openApiNullable}}
{{/openApiNullable}}
Loading