MigrationTrait creates faulty php code with numbers without min/max
meneken17 opened this issue · comments
meneken17 commented
Describe the bug
To Reproduce
- .yaml file contains:
LocationAttributes:
type: object
properties:
name: Name
lat:
type: number
format: float
lon:
type: number
format: float
Location:
type: object
properties:
type: Type
id: ID
attributes: LocationAttributes
- generate api
- migrate
This will create ..._create_location_table.php
8| public function up()
9| {
10| Schema::create('location', function(Blueprint $table) {
11| $table->bigIncrements('id');
> 12| $table->float('lat', array, array);
13| $table->float('lon', array, array);
14| $table->timestamps();
15| });
16| }
Which will throw syntax error, unexpected ',', expecting '('
because array
expects arguments.
This is caused by MigrationTraits.php
line 124/125:
$max = empty($attrVal[ApiInterface::RAML_INTEGER_MAX]) ? PhpInterface::PHP_TYPES_ARRAY : $attrVal[ApiInterface::RAML_INTEGER_MAX];
$min = empty($attrVal[ApiInterface::RAML_INTEGER_MIN]) ? PhpInterface::PHP_TYPES_ARRAY : $attrVal[ApiInterface::RAML_INTEGER_MIN];
I am not quite sure what value would make sense here but array
apperantly not.
Arthur Kushman commented
Hi, thank u for exploring this bug and detailed description, I'll try to fix it right-away.
Arthur Kushman commented
Added default values for double/float types.