Skip to content

Commit 1827cb5

Browse files
committed
improve openapi types
1 parent de7c051 commit 1827cb5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

api.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9064,16 +9064,16 @@ class OpenApiRecordsBuilder
90649064
'integer' => ['type' => 'integer', 'format' => 'int32'],
90659065
'bigint' => ['type' => 'integer', 'format' => 'int64'],
90669066
'varchar' => ['type' => 'string'],
9067-
'clob' => ['type' => 'string'],
9067+
'clob' => ['type' => 'string', 'format' => 'large-string'], //custom format
90689068
'varbinary' => ['type' => 'string', 'format' => 'byte'],
9069-
'blob' => ['type' => 'string', 'format' => 'byte'],
9070-
'decimal' => ['type' => 'string'],
9069+
'blob' => ['type' => 'string', 'format' => 'large-byte'], //custom format
9070+
'decimal' => ['type' => 'string', 'format' => 'decimal'], //custom format
90719071
'float' => ['type' => 'number', 'format' => 'float'],
90729072
'double' => ['type' => 'number', 'format' => 'double'],
90739073
'date' => ['type' => 'string', 'format' => 'date'],
9074-
'time' => ['type' => 'string', 'format' => 'date-time'],
9074+
'time' => ['type' => 'string', 'format' => 'time'], //custom format
90759075
'timestamp' => ['type' => 'string', 'format' => 'date-time'],
9076-
'geometry' => ['type' => 'string'],
9076+
'geometry' => ['type' => 'string', 'format' => 'geometry'], //custom format
90779077
'boolean' => ['type' => 'boolean'],
90789078
];
90799079

@@ -9245,8 +9245,12 @@ private function setComponentSchema(string $tableName, array $references) /*: vo
92459245
}
92469246
$column = $table->getColumn($columnName);
92479247
$properties = $this->types[$column->getType()];
9248+
$properties['maxLength'] = $column->hasLength() ? $column->getLength() : 0;
9249+
$properties['nullable'] = $column->getNullable();
92489250
foreach ($properties as $key => $value) {
9249-
$this->openapi->set("$prefix|properties|$columnName|$key", $value);
9251+
if ($value) {
9252+
$this->openapi->set("$prefix|properties|$columnName|$key", $value);
9253+
}
92509254
}
92519255
if ($column->getPk()) {
92529256
$this->openapi->set("$prefix|properties|$columnName|x-primary-key", true);

0 commit comments

Comments
 (0)