Skip to content

Commit a70fb5b

Browse files
committed
read view based on pk convention
1 parent 2a542b4 commit a70fb5b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Tqdev/PhpCrudApi/OpenApi/OpenApiRecordsBuilder.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Tqdev\PhpCrudApi\OpenApi;
44

55
use Tqdev\PhpCrudApi\Column\ReflectionService;
6+
use Tqdev\PhpCrudApi\Column\Reflection\ReflectedColumn;
67
use Tqdev\PhpCrudApi\Middleware\Communication\VariableStore;
78
use Tqdev\PhpCrudApi\OpenApi\OpenApiDefinition;
8-
use Tqdev\PhpCrudApi\Column\Reflection\ReflectedColumn;
99

1010
class OpenApiRecordsBuilder
1111
{
@@ -23,16 +23,16 @@ class OpenApiRecordsBuilder
2323
'integer' => ['type' => 'integer', 'format' => 'int32'],
2424
'bigint' => ['type' => 'integer', 'format' => 'int64'],
2525
'varchar' => ['type' => 'string'],
26-
'clob' => ['type' => 'string', 'format' => 'large-string'], //custom format
26+
'clob' => ['type' => 'string', 'format' => 'large-string'], //custom format
2727
'varbinary' => ['type' => 'string', 'format' => 'byte'],
28-
'blob' => ['type' => 'string', 'format' => 'large-byte'], //custom format
29-
'decimal' => ['type' => 'string', 'format' => 'decimal'], //custom format
28+
'blob' => ['type' => 'string', 'format' => 'large-byte'], //custom format
29+
'decimal' => ['type' => 'string', 'format' => 'decimal'], //custom format
3030
'float' => ['type' => 'number', 'format' => 'float'],
3131
'double' => ['type' => 'number', 'format' => 'double'],
3232
'date' => ['type' => 'string', 'format' => 'date'],
33-
'time' => ['type' => 'string', 'format' => 'time'], //custom format
33+
'time' => ['type' => 'string', 'format' => 'time'], //custom format
3434
'timestamp' => ['type' => 'string', 'format' => 'date-time'],
35-
'geometry' => ['type' => 'string', 'format' => 'geometry'], //custom format
35+
'geometry' => ['type' => 'string', 'format' => 'geometry'], //custom format
3636
'boolean' => ['type' => 'boolean'],
3737
];
3838

@@ -222,7 +222,10 @@ private function setComponentSchema(string $tableName, array $references) /*: vo
222222
if (!$pkName && $operation != 'list') {
223223
continue;
224224
}
225-
if ($type != 'table' && $operation != 'list') {
225+
if ($type == 'view' && !in_array($operation, array('read', 'list'))) {
226+
continue;
227+
}
228+
if ($type == 'view' && !$pkName && $operation == 'read') {
226229
continue;
227230
}
228231
if ($operation == 'delete') {

0 commit comments

Comments
 (0)