forked from loafle/openapi-generator-original
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.
|
# 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"
|
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
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -261,24 +261,23 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Schema p) {
|
public String getTypeDeclaration(Schema p) {
|
||||||
String swaggerType = getSchemaType(p);
|
String openAPIType = getSchemaType(p);
|
||||||
|
|
||||||
if (p instanceof ArraySchema) {
|
if (p instanceof ArraySchema) {
|
||||||
ArraySchema ap = (ArraySchema) p;
|
ArraySchema ap = (ArraySchema) p;
|
||||||
Schema inner = ap.getItems();
|
Schema inner = ap.getItems();
|
||||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||||
}
|
} else if (isMapSchema(p)) {
|
||||||
if (isMapSchema(p)) {
|
|
||||||
Schema inner = (Schema) p.getAdditionalProperties();
|
Schema inner = (Schema) p.getAdditionalProperties();
|
||||||
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
|
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
|
||||||
}
|
} else if (p instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(p.getType())
|
||||||
if (p instanceof StringSchema || p instanceof DateSchema
|
|| p instanceof DateSchema
|
||||||
|| p instanceof DateTimeSchema || p instanceof FileSchema
|
|| p instanceof DateTimeSchema || p instanceof FileSchema
|
||||||
|| languageSpecificPrimitives.contains(swaggerType)) {
|
|| languageSpecificPrimitives.contains(openAPIType)) {
|
||||||
return toModelName(swaggerType);
|
return toModelName(openAPIType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "std::shared_ptr<" + swaggerType + ">";
|
return "std::shared_ptr<" + openAPIType + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -340,14 +339,14 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String swaggerType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
String type = null;
|
String type = null;
|
||||||
if (typeMapping.containsKey(swaggerType)) {
|
if (typeMapping.containsKey(openAPIType)) {
|
||||||
type = typeMapping.get(swaggerType);
|
type = typeMapping.get(openAPIType);
|
||||||
if (languageSpecificPrimitives.contains(type))
|
if (languageSpecificPrimitives.contains(type))
|
||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
} else
|
} else
|
||||||
type = swaggerType;
|
type = openAPIType;
|
||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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}}", {{#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}}
|
{{/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}}", {{#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}}
|
{{/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}}", {{#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}}
|
{{/isPrimitiveType}}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user