Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/generators/php-dt.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/php-laravel.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/php-lumen.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
1 change: 0 additions & 1 deletion docs/generators/php-mezzio-ph.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/php-slim-deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/php-slim4.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/php-symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>UploadedFile</li>
<li>\DateTime</li>
<li>array</li>
<li>bool</li>
<li>byte</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>DateTime</li>
<li>\DateTime</li>
<li>\SplFileObject</li>
<li>array</li>
<li>bool</li>
<li>boolean</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public AbstractPhpCodegen() {
"string",
"object",
"array",
"DateTime",
"\\DateTime",
"\\SplFileObject",
"mixed",
"number",
"void",
Expand All @@ -111,6 +112,7 @@ public AbstractPhpCodegen() {
typeMapping.put("long", "int");
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("decimal", "float");
typeMapping.put("double", "double");
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
Expand Down Expand Up @@ -341,19 +343,31 @@ public String getTypeDeclaration(String name) {
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
String type = null;

if (openAPIType == null) {
LOGGER.error("OpenAPI Type for {} is null. Default to UNKNOWN_OPENAPI_TYPE instead.", p.getName());
openAPIType = "UNKNOWN_OPENAPI_TYPE";
}

if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
return type;
} else if (instantiationTypes.containsKey(type)) {
return type;
}
/*
// comment out the following as php-dt, php-mezzio still need to treat DateTime, SplFileObject as objects
} else {
throw new RuntimeException("OpenAPI type `" + openAPIType + "` defined but can't mapped to language type." +
" Please report the issue via OpenAPI Generator github repo." +
" (if you're not using custom format with proper type mappings provided to openapi-generator)");
}
*/
} else {
type = openAPIType;
}
if (type == null) {
return null;
}

return toModelName(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public PhpDataTransferClientCodegen() {
//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");

// remove these from primitive types to make the output works
languageSpecificPrimitives.remove("\\DateTime");
languageSpecificPrimitives.remove("\\SplFileObject");

apiTemplateFiles.clear();
apiTestTemplateFiles.clear();
apiDocTemplateFiles.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public PhpMezzioPathHandlerServerCodegen() {
//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");

// remove these from primitive types to make the output works
languageSpecificPrimitives.remove("\\DateTime");
languageSpecificPrimitives.remove("\\SplFileObject");

embeddedTemplateDir = templateDir = "php-mezzio-ph";
invokerPackage = "App";
srcBasePath = "src" + File.separator + "App";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public PhpSymfonyServerCodegen() {
"number",
"void",
"byte",
"array"
"array",
"\\DateTime",
"UploadedFile"
)
);

Expand All @@ -174,6 +176,7 @@ public PhpSymfonyServerCodegen() {
typeMapping = new HashMap<String, String>();
typeMapping.put("integer", "int");
typeMapping.put("long", "int");
typeMapping.put("decimal", "float");
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("double", "double");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void simpleModelTest() {

final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
Assert.assertEquals(property3.complexType, "\\DateTime");
Assert.assertEquals(property3.complexType, null);
Assert.assertEquals(property3.dataType, "\\DateTime");
Assert.assertEquals(property3.name, "created_at");
Assert.assertEquals(property3.defaultValue, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Name | Type | Description | Notes
**number** | **float** | |
**float** | **float** | | [optional]
**double** | **double** | | [optional]
**decimal** | [**Decimal**](Decimal.md) | | [optional]
**decimal** | **float** | | [optional]
**string** | **string** | | [optional]
**byte** | **string** | |
**binary** | [**\SplFileObject**](\SplFileObject.md) | | [optional]
**date** | [**\DateTime**](\DateTime.md) | |
**date_time** | [**\DateTime**](\DateTime.md) | | [optional]
**binary** | **\SplFileObject** | | [optional]
**date** | **\DateTime** | |
**date_time** | **\DateTime** | | [optional]
**uuid** | **string** | | [optional]
**password** | **string** | |
**pattern_with_digits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | **string** | | [optional]
**date_time** | [**\DateTime**](\DateTime.md) | | [optional]
**date_time** | **\DateTime** | | [optional]
**map** | [**array<string,\OpenAPI\Client\Model\Animal>**](Animal.md) | | [optional]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Name | Type | Description | Notes
**number_prop** | **float** | | [optional]
**boolean_prop** | **bool** | | [optional]
**string_prop** | **string** | | [optional]
**date_prop** | [**\DateTime**](\DateTime.md) | | [optional]
**datetime_prop** | [**\DateTime**](\DateTime.md) | | [optional]
**date_prop** | **\DateTime** | | [optional]
**datetime_prop** | **\DateTime** | | [optional]
**array_nullable_prop** | **object[]** | | [optional]
**array_and_items_nullable_prop** | **object[]** | | [optional]
**array_items_nullable** | **object[]** | | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **int** | | [optional]
**pet_id** | **int** | | [optional]
**quantity** | **int** | | [optional]
**ship_date** | [**\DateTime**](\DateTime.md) | | [optional]
**ship_date** | **\DateTime** | | [optional]
**status** | **string** | Order Status | [optional]
**complete** | **bool** | | [optional] [default to false]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class FormatTest implements ModelInterface, ArrayAccess, \JsonSerializable
'number' => 'float',
'float' => 'float',
'double' => 'double',
'decimal' => 'Decimal',
'decimal' => 'float',
'string' => 'string',
'byte' => 'string',
'binary' => '\SplFileObject',
Expand Down Expand Up @@ -554,7 +554,7 @@ public function setDouble($double)
/**
* Gets decimal
*
* @return Decimal|null
* @return float|null
*/
public function getDecimal()
{
Expand All @@ -564,7 +564,7 @@ public function getDecimal()
/**
* Sets decimal
*
* @param Decimal|null $decimal decimal
* @param float|null $decimal decimal
*
* @return self
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if ($value !== null && !in_array($openAPIType, ['DateTime', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
$callable = [$openAPIType, 'getAllowableEnumValues'];
if (is_callable($callable)) {
/** array $callable */
Expand Down Expand Up @@ -330,7 +330,7 @@ public static function deserialize($data, $class, $httpHeaders = null)
}

/** @psalm-suppress ParadoxicalCondition */
if (in_array($class, ['DateTime', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
settype($data, $class);
return $data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FormatTest {
/** @var double $double */
private $double;

/** @var Decimal $decimal */
/** @var float $decimal */
private $decimal;

/** @var string $string */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
**id** | **int** | | [optional]
**petId** | **int** | | [optional]
**quantity** | **int** | | [optional]
**shipDate** | [**\DateTime**](\DateTime.md) | | [optional]
**shipDate** | **\DateTime** | | [optional]
**status** | **string** | Order Status | [optional]
**complete** | **bool** | | [optional] [default to false]

Expand Down