mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-29 04:00:51 +00:00
Revert "[C++][Restbed] Fix default values for Restbed Server generator" (#1027)
* Revert "[gradle plugin] Support Gradle 4.10 (#1011)" This reverts commit 131cf94fe4a03e79abc992e2cf3560a9174c5d2e. * Revert "[C++][Restbed] Fix default values for Restbed Server generator (#761)" This reverts commit f29ba97e8bb13598708db7ea2ee7a5288ad1bd0c.
This commit is contained in:
parent
131cf94fe4
commit
096ac567ce
@ -2742,8 +2742,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set default value
|
// set default value
|
||||||
|
if (parameterSchema.getDefault() != null) {
|
||||||
codegenParameter.defaultValue = toDefaultValue(parameterSchema);
|
codegenParameter.defaultValue = toDefaultValue(parameterSchema);
|
||||||
|
}
|
||||||
// TDOO revise collectionFormat
|
// TDOO revise collectionFormat
|
||||||
String collectionFormat = null;
|
String collectionFormat = null;
|
||||||
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
|
||||||
|
@ -25,19 +25,15 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.media.*;
|
import io.swagger.v3.oas.models.media.*;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||||
|
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CppRestbedServerCodegen.class);
|
|
||||||
|
|
||||||
public static final String DECLSPEC = "declspec";
|
public static final String DECLSPEC = "declspec";
|
||||||
public static final String DEFAULT_INCLUDE = "defaultInclude";
|
public static final String DEFAULT_INCLUDE = "defaultInclude";
|
||||||
|
|
||||||
@ -291,63 +287,25 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public String toDefaultValue(Schema p) {
|
public String toDefaultValue(Schema p) {
|
||||||
if (ModelUtils.isStringSchema(p)) {
|
if (ModelUtils.isStringSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return "\"" + p.getDefault().toString() + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"\"";
|
return "\"\"";
|
||||||
}
|
|
||||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString();
|
|
||||||
} else {
|
|
||||||
return "false";
|
return "false";
|
||||||
}
|
|
||||||
} else if (ModelUtils.isDateSchema(p)) {
|
} else if (ModelUtils.isDateSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return "\"" + p.getDefault().toString() + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"\"";
|
return "\"\"";
|
||||||
}
|
|
||||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return "\"" + p.getDefault().toString() + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"\"";
|
return "\"\"";
|
||||||
}
|
|
||||||
} else if (ModelUtils.isNumberSchema(p)) {
|
} else if (ModelUtils.isNumberSchema(p)) {
|
||||||
if (ModelUtils.isFloatSchema(p)) { // float
|
if (ModelUtils.isFloatSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString() + "f";
|
|
||||||
} else {
|
|
||||||
return "0.0f";
|
return "0.0f";
|
||||||
}
|
}
|
||||||
} else { // double
|
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString();
|
|
||||||
} else {
|
|
||||||
return "0.0";
|
return "0.0";
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||||
if (ModelUtils.isLongSchema(p)) { // long
|
if (ModelUtils.isLongSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString() + "L";
|
|
||||||
} else {
|
|
||||||
return "0L";
|
return "0L";
|
||||||
}
|
}
|
||||||
} else { // integer
|
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return p.getDefault().toString();
|
|
||||||
} else {
|
|
||||||
return "0";
|
return "0";
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
|
||||||
return "\"" + p.getDefault().toString() + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"\"";
|
return "\"\"";
|
||||||
}
|
|
||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||||
return "std::map<std::string, " + inner + ">()";
|
return "std::map<std::string, " + inner + ">()";
|
||||||
@ -361,7 +319,6 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
|||||||
} else if (!StringUtils.isEmpty(p.get$ref())) {
|
} else if (!StringUtils.isEmpty(p.get$ref())) {
|
||||||
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "nullptr";
|
return "nullptr";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the path params
|
// Getting the path params
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{{defaultValue}}});
|
const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{/hasPathParams}}
|
{{/hasPathParams}}
|
||||||
@ -84,7 +84,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the query params
|
// Getting the query params
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{{defaultValue}}});
|
const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{/hasQueryParams}}
|
{{/hasQueryParams}}
|
||||||
@ -93,7 +93,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the headers
|
// Getting the headers
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{{defaultValue}}});
|
const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
@ -140,7 +140,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the path params
|
// Getting the path params
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_path_parameter("{{paramName}}", {{{defaultValue}}});
|
const {{dataType}} {{paramName}} = request->get_path_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{/hasPathParams}}
|
{{/hasPathParams}}
|
||||||
@ -149,7 +149,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the query params
|
// Getting the query params
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_query_parameter("{{paramName}}", {{{defaultValue}}});
|
const {{dataType}} {{paramName}} = request->get_query_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{/hasQueryParams}}
|
{{/hasQueryParams}}
|
||||||
@ -158,7 +158,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
|||||||
// Getting the headers
|
// Getting the headers
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{{defaultValue}}});
|
const {{dataType}} {{paramName}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user