forked from loafle/openapi-generator-original
[PHP][Symfony] Further enhancements (#7001)
* Further enchancements for PHP-Symfony. Fixes issues described in #6999 * Ran shell script to update petstore sample
This commit is contained in:
committed by
William Cheng
parent
a565a94a06
commit
5d59dd10ec
@@ -140,7 +140,7 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC
|
||||
typeMapping.put("map", "array");
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
typeMapping.put("object", "array");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
@@ -346,6 +346,16 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC
|
||||
param.vendorExtensions.put("x-parameterType", typeHint);
|
||||
}
|
||||
|
||||
if (param.isContainer) {
|
||||
param.vendorExtensions.put("x-parameterType", getTypeHint(param.dataType+"[]"));
|
||||
}
|
||||
|
||||
// Create a variable to display the correct data type in comments for interfaces
|
||||
param.vendorExtensions.put("x-commentType", param.dataType);
|
||||
if (param.isContainer) {
|
||||
param.vendorExtensions.put("x-commentType", param.dataType+"[]");
|
||||
}
|
||||
|
||||
// Quote default values for strings
|
||||
// @todo: The default values for headers, forms and query params are handled
|
||||
// in DefaultCodegen fromParameter with no real possibility to override
|
||||
@@ -355,16 +365,14 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenResponse response : op.responses) {
|
||||
final String exception = SYMFONY_EXCEPTIONS.get(response.code);
|
||||
response.vendorExtensions.put("x-symfonyException", exception);
|
||||
response.vendorExtensions.put("x-symfonyExceptionSimple", extractSimpleName(exception));
|
||||
|
||||
// Add simple return type to response
|
||||
if (response.dataType != null) {
|
||||
final String dataType = extractSimpleName(response.dataType);
|
||||
response.vendorExtensions.put("x-simpleName", dataType);
|
||||
// Create a variable to display the correct return type in comments for interfaces
|
||||
if (op.returnType != null) {
|
||||
op.vendorExtensions.put("x-commentType", op.returnType);
|
||||
if (!op.returnTypeIsPrimitive) {
|
||||
op.vendorExtensions.put("x-commentType", op.returnType+"[]");
|
||||
}
|
||||
} else {
|
||||
op.vendorExtensions.put("x-commentType", "void");
|
||||
}
|
||||
|
||||
// Add operation's authentication methods to whole interface
|
||||
@@ -396,6 +404,12 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC
|
||||
var.vendorExtensions.put("x-parameterType", typeHint);
|
||||
}
|
||||
|
||||
// Create a variable to display the correct data type in comments for models
|
||||
var.vendorExtensions.put("x-commentType", var.datatype);
|
||||
if (var.isContainer) {
|
||||
var.vendorExtensions.put("x-commentType", var.datatype+"[]");
|
||||
}
|
||||
|
||||
if (var.isBoolean) {
|
||||
var.getter = var.getter.replaceAll("^get", "is");
|
||||
}
|
||||
@@ -448,13 +462,13 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
|
||||
if (p instanceof RefProperty) {
|
||||
|
||||
Reference in New Issue
Block a user