mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
fix string issue with restbed generator
This commit is contained in:
parent
665f0bd811
commit
6fef0a7ffe
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -l restbed -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/restbed"
|
||||
ags="$@ generate -l cpp-restbed-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/restbed"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -261,24 +261,23 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
*/
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
String swaggerType = getSchemaType(p);
|
||||
String openAPIType = getSchemaType(p);
|
||||
|
||||
if (p instanceof ArraySchema) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
if (isMapSchema(p)) {
|
||||
} else if (isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
if (p instanceof StringSchema || p instanceof DateSchema
|
||||
} else if (p instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(p.getType())
|
||||
|| p instanceof DateSchema
|
||||
|| p instanceof DateTimeSchema || p instanceof FileSchema
|
||||
|| languageSpecificPrimitives.contains(swaggerType)) {
|
||||
return toModelName(swaggerType);
|
||||
|| languageSpecificPrimitives.contains(openAPIType)) {
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
return "std::shared_ptr<" + swaggerType + ">";
|
||||
return "std::shared_ptr<" + openAPIType + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -340,14 +339,14 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
*/
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String swaggerType = super.getSchemaType(p);
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
} else
|
||||
type = swaggerType;
|
||||
type = openAPIType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the path params
|
||||
{{#pathParams}}
|
||||
{{#isPrimitiveType}}
|
||||
const {{dataType}} {{paramName}} = request->get_path_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||
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}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
@ -84,7 +84,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the query params
|
||||
{{#queryParams}}
|
||||
{{#isPrimitiveType}}
|
||||
const {{dataType}} {{paramName}} = request->get_query_parameter("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||
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}}
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
@ -93,7 +93,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Getting the headers
|
||||
{{#headerParams}}
|
||||
{{#isPrimitiveType}}
|
||||
const {{dataType}} {{paramName}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||
const {{{dataType}}} {{{paramName}}} = request->get_header("{{paramName}}", {{#isString}}""{{/isString}}{{#isInteger}}0{{/isInteger}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0f{{/isFloat}}{{#isDouble}}0.0{{/isDouble}});
|
||||
{{/isPrimitiveType}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
|
Loading…
Reference in New Issue
Block a user