Skip to content

Commit a9481db

Browse files
committed
Add openapi to columns endpoint
1 parent c68ae16 commit a9481db

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

api.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8291,8 +8291,31 @@ private function setComponentSchema() /*: void*/
82918291
$operationType = $operation . ucfirst($type);
82928292
$prefix = "components|schemas|$operationType";
82938293
$this->openapi->set("$prefix|type", "object");
8294-
$this->openapi->set("$prefix|properties|name|type", 'string');
8295-
$this->openapi->set("$prefix|properties|type|type", 'string');
8294+
switch ($type) {
8295+
case 'database':
8296+
$this->openapi->set("$prefix|properties|tables|type", 'array');
8297+
$this->openapi->set("$prefix|properties|tables|items|\$ref", "#/components/responses/readTable");
8298+
break;
8299+
case 'table':
8300+
$this->openapi->set("$prefix|properties|name|type", 'string');
8301+
$this->openapi->set("$prefix|properties|type|type", 'string');
8302+
$this->openapi->set("$prefix|properties|columns|type", 'array');
8303+
$this->openapi->set("$prefix|properties|columns|items|\$ref", "#/components/responses/readColumn");
8304+
break;
8305+
case 'column':
8306+
$this->openapi->set("$prefix|properties|name|type", 'string');
8307+
$this->openapi->set("$prefix|properties|type|type", 'string');
8308+
$this->openapi->set("$prefix|properties|length|type", 'integer');
8309+
$this->openapi->set("$prefix|properties|length|format", "int64");
8310+
$this->openapi->set("$prefix|properties|precision|type", 'integer');
8311+
$this->openapi->set("$prefix|properties|precision|format", "int64");
8312+
$this->openapi->set("$prefix|properties|scale|type", 'integer');
8313+
$this->openapi->set("$prefix|properties|scale|format", "int64");
8314+
$this->openapi->set("$prefix|properties|nullable|type", 'boolean');
8315+
$this->openapi->set("$prefix|properties|pk|type", 'boolean');
8316+
$this->openapi->set("$prefix|properties|fk|type", 'string');
8317+
break;
8318+
}
82968319
}
82978320
}
82988321
}

src/Tqdev/PhpCrudApi/OpenApi/OpenApiColumnsBuilder.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,31 @@ private function setComponentSchema() /*: void*/
101101
$operationType = $operation . ucfirst($type);
102102
$prefix = "components|schemas|$operationType";
103103
$this->openapi->set("$prefix|type", "object");
104-
$this->openapi->set("$prefix|properties|name|type", 'string');
105-
$this->openapi->set("$prefix|properties|type|type", 'string');
104+
switch ($type) {
105+
case 'database':
106+
$this->openapi->set("$prefix|properties|tables|type", 'array');
107+
$this->openapi->set("$prefix|properties|tables|items|\$ref", "#/components/responses/readTable");
108+
break;
109+
case 'table':
110+
$this->openapi->set("$prefix|properties|name|type", 'string');
111+
$this->openapi->set("$prefix|properties|type|type", 'string');
112+
$this->openapi->set("$prefix|properties|columns|type", 'array');
113+
$this->openapi->set("$prefix|properties|columns|items|\$ref", "#/components/responses/readColumn");
114+
break;
115+
case 'column':
116+
$this->openapi->set("$prefix|properties|name|type", 'string');
117+
$this->openapi->set("$prefix|properties|type|type", 'string');
118+
$this->openapi->set("$prefix|properties|length|type", 'integer');
119+
$this->openapi->set("$prefix|properties|length|format", "int64");
120+
$this->openapi->set("$prefix|properties|precision|type", 'integer');
121+
$this->openapi->set("$prefix|properties|precision|format", "int64");
122+
$this->openapi->set("$prefix|properties|scale|type", 'integer');
123+
$this->openapi->set("$prefix|properties|scale|format", "int64");
124+
$this->openapi->set("$prefix|properties|nullable|type", 'boolean');
125+
$this->openapi->set("$prefix|properties|pk|type", 'boolean');
126+
$this->openapi->set("$prefix|properties|fk|type", 'string');
127+
break;
128+
}
106129
}
107130
}
108131
}

0 commit comments

Comments
 (0)