forked from loafle/openapi-generator-original
[BUG][C++][cpp-pistache-server] An api receiving a std::optional parameter generates a org::openapitools::server::model::std::optional<...> that doesn't compile #18792 (#18793)
Solving this issue has for goal to reduce the amount of work required to resolve the [[C++] Error making the cpprestsdk generated files](https://github.com/OpenAPITools/openapi-generator/issues/6726) and to put the `cpp-pistache-server` generator a the "same compilation problems" level than the `cpp-restsdk` generator in font of the #6726.
This commit is contained in:
parent
8783ad8a18
commit
84ce2bfd14
@ -104,6 +104,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
|||||||
public boolean isArray;
|
public boolean isArray;
|
||||||
public boolean hasChildren;
|
public boolean hasChildren;
|
||||||
public boolean isMap;
|
public boolean isMap;
|
||||||
|
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
|
||||||
|
public boolean isOptional;
|
||||||
public boolean isNull;
|
public boolean isNull;
|
||||||
public boolean isVoid = false;
|
public boolean isVoid = false;
|
||||||
/**
|
/**
|
||||||
@ -741,6 +743,16 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
|||||||
this.isMap = isMap;
|
this.isMap = isMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsOptional() {
|
||||||
|
return isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsOptional(boolean isOptional) {
|
||||||
|
this.isOptional = isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIsArray() {
|
public boolean getIsArray() {
|
||||||
return isArray;
|
return isArray;
|
||||||
@ -1128,6 +1140,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
|||||||
isArray == that.isArray &&
|
isArray == that.isArray &&
|
||||||
hasChildren == that.hasChildren &&
|
hasChildren == that.hasChildren &&
|
||||||
isMap == that.isMap &&
|
isMap == that.isMap &&
|
||||||
|
isOptional == that.isOptional &&
|
||||||
isDeprecated == that.isDeprecated &&
|
isDeprecated == that.isDeprecated &&
|
||||||
hasReadOnly == that.hasReadOnly &&
|
hasReadOnly == that.hasReadOnly &&
|
||||||
hasOnlyReadOnly == that.hasOnlyReadOnly &&
|
hasOnlyReadOnly == that.hasOnlyReadOnly &&
|
||||||
@ -1221,7 +1234,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
|||||||
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
|
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
|
||||||
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
|
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
|
||||||
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
|
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
|
||||||
hasChildren, isMap, isDeprecated, hasReadOnly, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
|
hasChildren, isMap, isOptional, isDeprecated, hasReadOnly, hasOnlyReadOnly, getExternalDocumentation(), getVendorExtensions(),
|
||||||
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
|
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
|
||||||
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
|
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
|
||||||
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
|
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
|
||||||
@ -1296,6 +1309,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
|||||||
sb.append(", isArray=").append(isArray);
|
sb.append(", isArray=").append(isArray);
|
||||||
sb.append(", hasChildren=").append(hasChildren);
|
sb.append(", hasChildren=").append(hasChildren);
|
||||||
sb.append(", isMap=").append(isMap);
|
sb.append(", isMap=").append(isMap);
|
||||||
|
sb.append(", isOptional=").append(isOptional);
|
||||||
sb.append(", isDeprecated=").append(isDeprecated);
|
sb.append(", isDeprecated=").append(isDeprecated);
|
||||||
sb.append(", hasReadOnly=").append(hasReadOnly);
|
sb.append(", hasReadOnly=").append(hasReadOnly);
|
||||||
sb.append(", hasOnlyReadOnly=").append(hasOnlyReadOnly);
|
sb.append(", hasOnlyReadOnly=").append(hasOnlyReadOnly);
|
||||||
|
@ -48,6 +48,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
|
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
|
||||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
|
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
|
||||||
public boolean isArray, isMap;
|
public boolean isArray, isMap;
|
||||||
|
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
|
||||||
|
public boolean isOptional;
|
||||||
public boolean isFile;
|
public boolean isFile;
|
||||||
public boolean isEnum;
|
public boolean isEnum;
|
||||||
public boolean isEnumRef; // true if the enum is a ref (model) but not defined inline
|
public boolean isEnumRef; // true if the enum is a ref (model) but not defined inline
|
||||||
@ -261,6 +263,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
output.isAnyType = this.isAnyType;
|
output.isAnyType = this.isAnyType;
|
||||||
output.isArray = this.isArray;
|
output.isArray = this.isArray;
|
||||||
output.isMap = this.isMap;
|
output.isMap = this.isMap;
|
||||||
|
output.isOptional = this.isOptional;
|
||||||
output.isExplode = this.isExplode;
|
output.isExplode = this.isExplode;
|
||||||
output.style = this.style;
|
output.style = this.style;
|
||||||
output.isDeepObject = this.isDeepObject;
|
output.isDeepObject = this.isDeepObject;
|
||||||
@ -280,7 +283,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
|
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
|
||||||
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
|
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
|
||||||
isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
|
isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
|
||||||
isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, isEnumRef, _enum, allowableValues,
|
isFreeFormObject, isAnyType, isArray, isMap, isOptional, isFile, isEnum, isEnumRef, _enum, allowableValues,
|
||||||
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
|
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
|
||||||
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
|
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
|
||||||
getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(),
|
getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(),
|
||||||
@ -330,6 +333,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
isAnyType == that.isAnyType &&
|
isAnyType == that.isAnyType &&
|
||||||
isArray == that.isArray &&
|
isArray == that.isArray &&
|
||||||
isMap == that.isMap &&
|
isMap == that.isMap &&
|
||||||
|
isOptional == that.isOptional &&
|
||||||
isFile == that.isFile &&
|
isFile == that.isFile &&
|
||||||
isEnum == that.isEnum &&
|
isEnum == that.isEnum &&
|
||||||
isEnumRef == that.isEnumRef &&
|
isEnumRef == that.isEnumRef &&
|
||||||
@ -463,6 +467,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
sb.append(", isAnyType=").append(isAnyType);
|
sb.append(", isAnyType=").append(isAnyType);
|
||||||
sb.append(", isArray=").append(isArray);
|
sb.append(", isArray=").append(isArray);
|
||||||
sb.append(", isMap=").append(isMap);
|
sb.append(", isMap=").append(isMap);
|
||||||
|
sb.append(", isOptional=").append(isOptional);
|
||||||
sb.append(", isFile=").append(isFile);
|
sb.append(", isFile=").append(isFile);
|
||||||
sb.append(", isEnum=").append(isEnum);
|
sb.append(", isEnum=").append(isEnum);
|
||||||
sb.append(", isEnumRef=").append(isEnumRef);
|
sb.append(", isEnumRef=").append(isEnumRef);
|
||||||
@ -755,6 +760,16 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
|||||||
this.isMap = isMap;
|
this.isMap = isMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsOptional() {
|
||||||
|
return isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsOptional(boolean isOptional) {
|
||||||
|
this.isOptional = isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIsArray() {
|
public boolean getIsArray() {
|
||||||
return isArray;
|
return isArray;
|
||||||
|
@ -157,6 +157,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
public boolean isAnyType;
|
public boolean isAnyType;
|
||||||
public boolean isArray;
|
public boolean isArray;
|
||||||
public boolean isMap;
|
public boolean isMap;
|
||||||
|
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
|
||||||
|
public boolean isOptional;
|
||||||
public boolean isEnum; // true if the enum is defined inline
|
public boolean isEnum; // true if the enum is defined inline
|
||||||
public boolean isInnerEnum; // Enums declared inline will be located inside the generic model, changing how the enum is referenced in some cases.
|
public boolean isInnerEnum; // Enums declared inline will be located inside the generic model, changing how the enum is referenced in some cases.
|
||||||
public boolean isEnumRef; // true if it's a reference to an enum
|
public boolean isEnumRef; // true if it's a reference to an enum
|
||||||
@ -625,6 +627,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
this.isMap = isMap;
|
this.isMap = isMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsOptional() {
|
||||||
|
return isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsOptional(boolean isOptional) {
|
||||||
|
this.isOptional = isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIsArray() {
|
public boolean getIsArray() {
|
||||||
return isArray;
|
return isArray;
|
||||||
@ -1200,6 +1212,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
sb.append(", isFreeFormObject=").append(isFreeFormObject);
|
sb.append(", isFreeFormObject=").append(isFreeFormObject);
|
||||||
sb.append(", isArray=").append(isArray);
|
sb.append(", isArray=").append(isArray);
|
||||||
sb.append(", isMap=").append(isMap);
|
sb.append(", isMap=").append(isMap);
|
||||||
|
sb.append(", isOptional=").append(isOptional);
|
||||||
sb.append(", isEnum=").append(isEnum);
|
sb.append(", isEnum=").append(isEnum);
|
||||||
sb.append(", isInnerEnum=").append(isInnerEnum);
|
sb.append(", isInnerEnum=").append(isInnerEnum);
|
||||||
sb.append(", isEnumRef=").append(isEnumRef);
|
sb.append(", isEnumRef=").append(isEnumRef);
|
||||||
@ -1295,6 +1308,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
isFreeFormObject == that.isFreeFormObject &&
|
isFreeFormObject == that.isFreeFormObject &&
|
||||||
isArray == that.isArray &&
|
isArray == that.isArray &&
|
||||||
isMap == that.isMap &&
|
isMap == that.isMap &&
|
||||||
|
isOptional == that.isOptional &&
|
||||||
isEnum == that.isEnum &&
|
isEnum == that.isEnum &&
|
||||||
isInnerEnum == that.isInnerEnum &&
|
isInnerEnum == that.isInnerEnum &&
|
||||||
isEnumRef == that.isEnumRef &&
|
isEnumRef == that.isEnumRef &&
|
||||||
@ -1386,7 +1400,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
|
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
|
||||||
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
|
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
|
||||||
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
|
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
|
||||||
isArray, isMap, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
|
isArray, isMap, isOptional, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
|
||||||
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
|
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
|
||||||
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
|
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
|
||||||
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInPascalCase, nameInCamelCase,
|
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInPascalCase, nameInCamelCase,
|
||||||
|
@ -59,6 +59,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
|||||||
public boolean simpleType;
|
public boolean simpleType;
|
||||||
public boolean primitiveType;
|
public boolean primitiveType;
|
||||||
public boolean isMap;
|
public boolean isMap;
|
||||||
|
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
|
||||||
|
public boolean isOptional;
|
||||||
public boolean isArray;
|
public boolean isArray;
|
||||||
public boolean isBinary = false;
|
public boolean isBinary = false;
|
||||||
public boolean isFile = false;
|
public boolean isFile = false;
|
||||||
@ -103,7 +105,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
|||||||
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders,
|
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders,
|
||||||
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
|
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
|
||||||
isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
|
isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
|
||||||
isMap, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
|
isMap, isOptional, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
|
||||||
vars, requiredVars, isNull, isVoid, hasValidation, isShort, isUnboundedInteger,
|
vars, requiredVars, isNull, isVoid, hasValidation, isShort, isUnboundedInteger,
|
||||||
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
|
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
|
||||||
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
|
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
|
||||||
@ -142,6 +144,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
|||||||
simpleType == that.simpleType &&
|
simpleType == that.simpleType &&
|
||||||
primitiveType == that.primitiveType &&
|
primitiveType == that.primitiveType &&
|
||||||
isMap == that.isMap &&
|
isMap == that.isMap &&
|
||||||
|
isOptional == that.isOptional &&
|
||||||
isArray == that.isArray &&
|
isArray == that.isArray &&
|
||||||
isBinary == that.isBinary &&
|
isBinary == that.isBinary &&
|
||||||
isFile == that.isFile &&
|
isFile == that.isFile &&
|
||||||
@ -503,6 +506,16 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
|||||||
this.isMap = isMap;
|
this.isMap = isMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsOptional() {
|
||||||
|
return isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsOptional(boolean isOptional) {
|
||||||
|
this.isOptional = isOptional;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenProperty getAdditionalProperties() {
|
public CodegenProperty getAdditionalProperties() {
|
||||||
return additionalProperties;
|
return additionalProperties;
|
||||||
@ -594,6 +607,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
|||||||
sb.append(", simpleType=").append(simpleType);
|
sb.append(", simpleType=").append(simpleType);
|
||||||
sb.append(", primitiveType=").append(primitiveType);
|
sb.append(", primitiveType=").append(primitiveType);
|
||||||
sb.append(", isMap=").append(isMap);
|
sb.append(", isMap=").append(isMap);
|
||||||
|
sb.append(", isOptional=").append(isOptional);
|
||||||
sb.append(", isArray=").append(isArray);
|
sb.append(", isArray=").append(isArray);
|
||||||
sb.append(", isBinary=").append(isBinary);
|
sb.append(", isBinary=").append(isBinary);
|
||||||
sb.append(", isFile=").append(isFile);
|
sb.append(", isFile=").append(isFile);
|
||||||
|
@ -105,6 +105,18 @@ public interface IJsonSchemaValidationProperties {
|
|||||||
|
|
||||||
void setIsMap(boolean isMap);
|
void setIsMap(boolean isMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells if the datatype is a generic inner parameter of a <code>std::optional</code> for C++, or <code>Optional</code> (Java)<br>
|
||||||
|
* to resolve cases (detected in issue #6726) where :<br>
|
||||||
|
* - <code>categoryOneOf</code> is a parameter of class <code>GetAccountVideos_categoryOneOf_parameter</code>, a model parameter that correctly prefixed by its namespace: <code>org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter</code><br>
|
||||||
|
* - but that <code>GetAccountVideos_categoryOneOf_parameter</code> class is inside an <code>std::optional</code><br>
|
||||||
|
* <br>
|
||||||
|
* Then a correct generation of that parameter can be (for C++) <code>const std::optional<org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter> &categoryOneOf</code><br>
|
||||||
|
* but using #isModel alone without #isOptional in mustache might produce <code>const org::openapitools::server::model::std::optional<org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter> &categoryOneOf</code> instead, that do not compile.
|
||||||
|
*/
|
||||||
|
boolean getIsOptional();
|
||||||
|
void setIsOptional(boolean isOptional);
|
||||||
|
|
||||||
boolean getIsArray();
|
boolean getIsArray();
|
||||||
|
|
||||||
void setIsArray(boolean isShort);
|
void setIsArray(boolean isShort);
|
||||||
|
@ -356,13 +356,17 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
|||||||
* data types for Header and Query parameters.
|
* data types for Header and Query parameters.
|
||||||
* @param param CodegenParameter to be modified.
|
* @param param CodegenParameter to be modified.
|
||||||
*/
|
*/
|
||||||
private static void postProcessSingleParam(CodegenParameter param) {
|
private void postProcessSingleParam(CodegenParameter param) {
|
||||||
//TODO: This changes the info about the real type but it is needed to parse the header params
|
//TODO: This changes the info about the real type but it is needed to parse the header params
|
||||||
if (param.isHeaderParam) {
|
if (param.isHeaderParam) {
|
||||||
param.dataType = "std::optional<Pistache::Http::Header::Raw>";
|
param.dataType = "std::optional<Pistache::Http::Header::Raw>";
|
||||||
param.baseType = "std::optional<Pistache::Http::Header::Raw>";
|
param.baseType = "std::optional<Pistache::Http::Header::Raw>";
|
||||||
} else if (param.isQueryParam) {
|
} else if (param.isQueryParam) {
|
||||||
param.dataType = "std::optional<" + param.dataType + ">";
|
String dataTypeWithNamespace = param.isPrimitiveType ? param.dataType : prefixWithNameSpaceIfNeeded(param.dataType);
|
||||||
|
|
||||||
|
param.dataType = "std::optional<" + dataTypeWithNamespace + ">";
|
||||||
|
param.isOptional = true;
|
||||||
|
|
||||||
if (!param.isPrimitiveType) {
|
if (!param.isPrimitiveType) {
|
||||||
param.baseType = "std::optional<" + param.baseType + ">";
|
param.baseType = "std::optional<" + param.baseType + ">";
|
||||||
}
|
}
|
||||||
@ -434,8 +438,17 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
|||||||
return toModelName(openAPIType);
|
return toModelName(openAPIType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return prefixWithNameSpaceIfNeeded(openAPIType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix an open API type with a namespace or not, depending of its current type and if it is on a list to avoid it.
|
||||||
|
* @param openAPIType Open API Type.
|
||||||
|
* @return type prefixed with the namespace or not.
|
||||||
|
*/
|
||||||
|
private String prefixWithNameSpaceIfNeeded(String openAPIType) {
|
||||||
// Some types might not support namespace
|
// Some types might not support namespace
|
||||||
if (this.openAPITypesWithoutModelNamespace.contains(openAPIType)) {
|
if (this.openAPITypesWithoutModelNamespace.contains(openAPIType) || openAPIType.startsWith("std::")) {
|
||||||
return openAPIType;
|
return openAPIType;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -65,7 +65,7 @@ private:
|
|||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{modelNamespace}}::{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0;
|
virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{^isOptional}}{{modelNamespace}}::{{/isOptional}}{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0;
|
||||||
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
|
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
|
||||||
{{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
|
{{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
|
||||||
virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
|
virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
|
||||||
|
@ -32,6 +32,7 @@ public class ObjectAnyTypeSetTest extends AbstractGeneratorsTest {
|
|||||||
|
|
||||||
/** A Petstore inputspec with abstract properties added in the Pet */
|
/** A Petstore inputspec with abstract properties added in the Pet */
|
||||||
private static final String INPUT_SPEC = "src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml";
|
private static final String INPUT_SPEC = "src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml";
|
||||||
|
private static final String ISSUE_6726 = "src/test/resources/3_0/issue_6726.yaml";
|
||||||
|
|
||||||
/** Soft assert to check all the generators before eventually failing a test */
|
/** Soft assert to check all the generators before eventually failing a test */
|
||||||
private final SoftAssert softAssert = new SoftAssert();
|
private final SoftAssert softAssert = new SoftAssert();
|
||||||
@ -44,7 +45,7 @@ public class ObjectAnyTypeSetTest extends AbstractGeneratorsTest {
|
|||||||
public void testSomeWithPetstoreWithAbstract() throws IOException {
|
public void testSomeWithPetstoreWithAbstract() throws IOException {
|
||||||
// assertGeneratedFiles("c");
|
// assertGeneratedFiles("c");
|
||||||
// assertGeneratedFiles("cpp-restsdk");
|
// assertGeneratedFiles("cpp-restsdk");
|
||||||
generateFiles("cpp-pistache-server");
|
generateFiles("cpp-pistache-server", ISSUE_6726);
|
||||||
// assertGeneratedFiles("typescript");
|
// assertGeneratedFiles("typescript");
|
||||||
this.softAssert.assertAll();
|
this.softAssert.assertAll();
|
||||||
}
|
}
|
||||||
@ -52,11 +53,12 @@ public class ObjectAnyTypeSetTest extends AbstractGeneratorsTest {
|
|||||||
/**
|
/**
|
||||||
* Asserts that a generator has produced some files
|
* Asserts that a generator has produced some files
|
||||||
* @param generatorName The generator name to test
|
* @param generatorName The generator name to test
|
||||||
|
* @param inputSpec The inputspec to use.
|
||||||
* @return List of files generated
|
* @return List of files generated
|
||||||
* @throws IOException if the test folder cannot be created
|
* @throws IOException if the test folder cannot be created
|
||||||
*/
|
*/
|
||||||
private List<File> generateFiles(String generatorName) throws IOException {
|
private List<File> generateFiles(String generatorName, String inputSpec) throws IOException {
|
||||||
Objects.requireNonNull(generatorName, "A generator name is expected for this assertion");
|
Objects.requireNonNull(generatorName, "A generator name is expected for this assertion");
|
||||||
return oneWith(generatorName, INPUT_SPEC);
|
return oneWith(generatorName, inputSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10555
modules/openapi-generator/src/test/resources/3_0/issue_6726.yaml
Normal file
10555
modules/openapi-generator/src/test/resources/3_0/issue_6726.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -577,13 +577,13 @@ public interface PathHandlerInterface {
|
|||||||
* <p><b>Response headers</b>: [CodegenProperty{openApiType='string', baseName='Set-Cookie', complexType='null', getter='getSetCookie', setter='setSetCookie', description='Cookie authentication key for use with the `api_key` apiKey authentication.', dataType='String', datatypeWithEnum='String', dataFormat='null', name='setCookie', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.Set-Cookie;', baseType='String', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='Cookie authentication key for use with the `api_key` apiKey authentication.', maxLength=null, minLength=null, pattern='null', example='AUTH_KEY=abcde12345; Path=/; HttpOnly', jsonSchema='{
|
* <p><b>Response headers</b>: [CodegenProperty{openApiType='string', baseName='Set-Cookie', complexType='null', getter='getSetCookie', setter='setSetCookie', description='Cookie authentication key for use with the `api_key` apiKey authentication.', dataType='String', datatypeWithEnum='String', dataFormat='null', name='setCookie', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.Set-Cookie;', baseType='String', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='Cookie authentication key for use with the `api_key` apiKey authentication.', maxLength=null, minLength=null, pattern='null', example='AUTH_KEY=abcde12345; Path=/; HttpOnly', jsonSchema='{
|
||||||
"example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly",
|
"example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=true, isNumeric=false, isInteger=false, isShort=false, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='setCookie', nameInPascalCase='SetCookie', nameInSnakeCase='SET_COOKIE', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=null, dependentRequired=null, contains=null}, CodegenProperty{openApiType='integer', baseName='X-Rate-Limit', complexType='null', getter='getxRateLimit', setter='setxRateLimit', description='calls per hour allowed by the user', dataType='Integer', datatypeWithEnum='Integer', dataFormat='int32', name='xRateLimit', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Rate-Limit;', baseType='Integer', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='calls per hour allowed by the user', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
|
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=true, isNumeric=false, isInteger=false, isShort=false, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isOptional=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='setCookie', nameInPascalCase='SetCookie', nameInSnakeCase='SET_COOKIE', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=null, dependentRequired=null, contains=null}, CodegenProperty{openApiType='integer', baseName='X-Rate-Limit', complexType='null', getter='getxRateLimit', setter='setxRateLimit', description='calls per hour allowed by the user', dataType='Integer', datatypeWithEnum='Integer', dataFormat='int32', name='xRateLimit', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Rate-Limit;', baseType='Integer', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='calls per hour allowed by the user', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
|
||||||
"format" : "int32",
|
"format" : "int32",
|
||||||
"type" : "integer"
|
"type" : "integer"
|
||||||
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isShort=true, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='xRateLimit', nameInPascalCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=int32, dependentRequired=null, contains=null}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when token expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='date in UTC when token expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
|
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=true, isModel=false, isContainer=false, isString=false, isNumeric=true, isInteger=true, isShort=true, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=false, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isOptional=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='xRateLimit', nameInPascalCase='XRateLimit', nameInSnakeCase='X_RATE_LIMIT', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=int32, dependentRequired=null, contains=null}, CodegenProperty{openApiType='string', baseName='X-Expires-After', complexType='Date', getter='getxExpiresAfter', setter='setxExpiresAfter', description='date in UTC when token expires', dataType='Date', datatypeWithEnum='Date', dataFormat='date-time', name='xExpiresAfter', min='null', max='null', defaultValue='null', defaultValueWithParam=' = data.X-Expires-After;', baseType='Date', containerType='null', containerTypeMapped='null', title='null', unescapedDescription='date in UTC when token expires', maxLength=null, minLength=null, pattern='null', example='null', jsonSchema='{
|
||||||
"format" : "date-time",
|
"format" : "date-time",
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=false, isModel=false, isContainer=false, isString=false, isNumeric=false, isInteger=false, isShort=false, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=true, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='xExpiresAfter', nameInPascalCase='XExpiresAfter', nameInSnakeCase='X_EXPIRES_AFTER', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=date-time, dependentRequired=null, contains=null}]</p>
|
}', minimum='null', maximum='null', exclusiveMinimum=false, exclusiveMaximum=false, required=false, deprecated=false, hasMoreNonReadOnly=false, isPrimitiveType=false, isModel=false, isContainer=false, isString=false, isNumeric=false, isInteger=false, isShort=false, isLong=false, isUnboundedInteger=false, isNumber=false, isFloat=false, isDouble=false, isDecimal=false, isByteArray=false, isBinary=false, isFile=false, isBoolean=false, isDate=false, isDateTime=true, isUuid=false, isUri=false, isEmail=false, isPassword=false, isFreeFormObject=false, isArray=false, isMap=false, isOptional=false, isEnum=false, isInnerEnum=false, isEnumRef=false, isAnyType=false, isReadOnly=false, isWriteOnly=false, isNullable=false, isSelfReference=false, isCircularReference=false, isDiscriminator=false, isNew=false, isOverridden=null, _enum=null, allowableValues=null, items=null, additionalProperties=null, vars=[], requiredVars=[], mostInnerItems=null, vendorExtensions={}, hasValidation=false, isInherited=false, discriminatorValue='null', nameInCamelCase='xExpiresAfter', nameInPascalCase='XExpiresAfter', nameInSnakeCase='X_EXPIRES_AFTER', enumName='null', maxItems=null, minItems=null, maxProperties=null, minProperties=null, uniqueItems=false, uniqueItemsBoolean=null, multipleOf=null, isXmlAttribute=false, xmlPrefix='null', xmlName='null', xmlNamespace='null', isXmlWrapped=false, isNull=false, isVoid=false, getAdditionalPropertiesIsAnyType=false, getHasVars=false, getHasRequired=false, getHasDiscriminatorWithNonEmptyMapping=false, composedSchemas=null, hasMultipleTypes=false, requiredVarsMap=null, ref=null, schemaIsFromAdditionalProperties=false, isBooleanSchemaTrue=false, isBooleanSchemaFalse=false, format=date-time, dependentRequired=null, contains=null}]</p>
|
||||||
*
|
*
|
||||||
* <p><b>Produces</b>: [{isXml=true, mediaType=application/xml}, {isJson=true, mediaType=application/json}]</p>
|
* <p><b>Produces</b>: [{isXml=true, mediaType=application/xml}, {isJson=true, mediaType=application/json}]</p>
|
||||||
* <p><b>Returns</b>: {@link String}</p>
|
* <p><b>Returns</b>: {@link String}</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user