Skip to content

Commit

Permalink
fix for #904
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Sep 5, 2022
1 parent 0229253 commit 3051700
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 72 deletions.
48 changes: 24 additions & 24 deletions api.include.php
Expand Up @@ -9643,7 +9643,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
{
$this->openapi->set("openapi", "3.0.0");
if (!$this->openapi->has("servers")) {
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
$this->openapi->set("servers||url", $this->getServerUrl($request));
}
if ($this->records) {
$this->records->build();
Expand Down Expand Up @@ -9702,8 +9702,8 @@ public function build() /*: void*/
$this->setComponentResponse();
$this->setComponentRequestBody();
$this->setComponentParameters();
foreach (array_keys($this->operations) as $index => $type) {
$this->setTag($index, $type);
foreach (array_keys($this->operations) as $type) {
$this->setTag($type);
}
}

Expand All @@ -9729,13 +9729,13 @@ private function setPaths() /*: void*/
if (strpos($path, '{column}')) {
$parameters[] = 'column';
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
}
$this->openapi->set("paths|$path|$method|tags|0", "$type");
$this->openapi->set("paths|$path|$method|tags|", "$type");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
if ("$operation-$type" == 'update-table') {
$this->openapi->set("paths|$path|$method|description", "rename table");
Expand Down Expand Up @@ -9843,10 +9843,9 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|column|required", true);
}

private function setTag(int $index, string $type) /*: void*/
private function setTag(string $type) /*: void*/
{
$this->openapi->set("tags|$index|name", "$type");
$this->openapi->set("tags|$index|description", "$type operations");
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
}
}
}
Expand All @@ -9865,10 +9864,13 @@ public function __construct(array $base)

public function set(string $path, $value) /*: void*/
{
$parts = explode('|', trim($path, '|'));
$parts = explode('|', $path);
$current = &$this->root;
while (count($parts) > 0) {
$part = array_shift($parts);
if ($part === '') {
$part = count($current);
}
if (!isset($current[$part])) {
$current[$part] = [];
}
Expand Down Expand Up @@ -9989,8 +9991,8 @@ public function build() /*: void*/
$this->setComponentRequestBody($tableName);
}
$this->setComponentParameters();
foreach ($tableNames as $index => $tableName) {
$this->setTag($index, $tableName);
foreach ($tableNames as $tableName) {
$this->setTag($tableName);
}
}

Expand Down Expand Up @@ -10043,13 +10045,13 @@ private function setPath(string $tableName) /*: void*/
$parameters = ['pk'];
}
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update', 'increment'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
}
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
switch ($operation) {
Expand Down Expand Up @@ -10275,10 +10277,9 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|join|required", false);
}

private function setTag(int $index, string $tableName) /*: void*/
private function setTag(string $tableName) /*: void*/
{
$this->openapi->set("tags|$index|name", "$tableName");
$this->openapi->set("tags|$index|description", "$tableName operations");
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
}
}
}
Expand Down Expand Up @@ -10331,8 +10332,8 @@ public function build() /*: void*/
$this->setPaths();
$this->setComponentSchema();
$this->setComponentResponse();
foreach (array_keys($this->operations) as $index => $type) {
$this->setTag($index, $type);
foreach (array_keys($this->operations) as $type) {
$this->setTag($type);
}
}

Expand All @@ -10341,7 +10342,7 @@ private function setPaths() /*: void*/
foreach ($this->operations as $type => $operationPair) {
foreach ($operationPair as $operation => $method) {
$path = "/$type/$operation";
$this->openapi->set("paths|$path|$method|tags|0", "$type");
$this->openapi->set("paths|$path|$method|tags|", "$type");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
$this->openapi->set("paths|$path|$method|description", "Request API '$operation' status");
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
Expand Down Expand Up @@ -10379,10 +10380,9 @@ private function setComponentResponse() /*: void*/
}
}

private function setTag(int $index, string $type) /*: void*/
private function setTag(string $type) /*: void*/
{
$this->openapi->set("tags|$index|name", "$type");
$this->openapi->set("tags|$index|description", "$type operations");
$this->openapi->set("tags|", [ 'name' => $type, 'description' => "$type operations"]);
}
}
}
Expand Down
48 changes: 24 additions & 24 deletions api.php
Expand Up @@ -9643,7 +9643,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
{
$this->openapi->set("openapi", "3.0.0");
if (!$this->openapi->has("servers")) {
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
$this->openapi->set("servers||url", $this->getServerUrl($request));
}
if ($this->records) {
$this->records->build();
Expand Down Expand Up @@ -9702,8 +9702,8 @@ public function build() /*: void*/
$this->setComponentResponse();
$this->setComponentRequestBody();
$this->setComponentParameters();
foreach (array_keys($this->operations) as $index => $type) {
$this->setTag($index, $type);
foreach (array_keys($this->operations) as $type) {
$this->setTag($type);
}
}

Expand All @@ -9729,13 +9729,13 @@ private function setPaths() /*: void*/
if (strpos($path, '{column}')) {
$parameters[] = 'column';
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
}
$this->openapi->set("paths|$path|$method|tags|0", "$type");
$this->openapi->set("paths|$path|$method|tags|", "$type");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
if ("$operation-$type" == 'update-table') {
$this->openapi->set("paths|$path|$method|description", "rename table");
Expand Down Expand Up @@ -9843,10 +9843,9 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|column|required", true);
}

private function setTag(int $index, string $type) /*: void*/
private function setTag(string $type) /*: void*/
{
$this->openapi->set("tags|$index|name", "$type");
$this->openapi->set("tags|$index|description", "$type operations");
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
}
}
}
Expand All @@ -9865,10 +9864,13 @@ public function __construct(array $base)

public function set(string $path, $value) /*: void*/
{
$parts = explode('|', trim($path, '|'));
$parts = explode('|', $path);
$current = &$this->root;
while (count($parts) > 0) {
$part = array_shift($parts);
if ($part === '') {
$part = count($current);
}
if (!isset($current[$part])) {
$current[$part] = [];
}
Expand Down Expand Up @@ -9989,8 +9991,8 @@ public function build() /*: void*/
$this->setComponentRequestBody($tableName);
}
$this->setComponentParameters();
foreach ($tableNames as $index => $tableName) {
$this->setTag($index, $tableName);
foreach ($tableNames as $tableName) {
$this->setTag($tableName);
}
}

Expand Down Expand Up @@ -10043,13 +10045,13 @@ private function setPath(string $tableName) /*: void*/
$parameters = ['pk'];
}
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update', 'increment'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
}
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
switch ($operation) {
Expand Down Expand Up @@ -10275,10 +10277,9 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|join|required", false);
}

private function setTag(int $index, string $tableName) /*: void*/
private function setTag(string $tableName) /*: void*/
{
$this->openapi->set("tags|$index|name", "$tableName");
$this->openapi->set("tags|$index|description", "$tableName operations");
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
}
}
}
Expand Down Expand Up @@ -10331,8 +10332,8 @@ public function build() /*: void*/
$this->setPaths();
$this->setComponentSchema();
$this->setComponentResponse();
foreach (array_keys($this->operations) as $index => $type) {
$this->setTag($index, $type);
foreach (array_keys($this->operations) as $type) {
$this->setTag($type);
}
}

Expand All @@ -10341,7 +10342,7 @@ private function setPaths() /*: void*/
foreach ($this->operations as $type => $operationPair) {
foreach ($operationPair as $operation => $method) {
$path = "/$type/$operation";
$this->openapi->set("paths|$path|$method|tags|0", "$type");
$this->openapi->set("paths|$path|$method|tags|", "$type");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
$this->openapi->set("paths|$path|$method|description", "Request API '$operation' status");
$this->openapi->set("paths|$path|$method|responses|200|\$ref", "#/components/responses/$operation-$type");
Expand Down Expand Up @@ -10379,10 +10380,9 @@ private function setComponentResponse() /*: void*/
}
}

private function setTag(int $index, string $type) /*: void*/
private function setTag(string $type) /*: void*/
{
$this->openapi->set("tags|$index|name", "$type");
$this->openapi->set("tags|$index|description", "$type operations");
$this->openapi->set("tags|", [ 'name' => $type, 'description' => "$type operations"]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tqdev/PhpCrudApi/OpenApi/OpenApiBuilder.php
Expand Up @@ -37,7 +37,7 @@ public function build(ServerRequestInterface $request): OpenApiDefinition
{
$this->openapi->set("openapi", "3.0.0");
if (!$this->openapi->has("servers")) {
$this->openapi->set("servers|0|url", $this->getServerUrl($request));
$this->openapi->set("servers||url", $this->getServerUrl($request));
}
if ($this->records) {
$this->records->build();
Expand Down
15 changes: 7 additions & 8 deletions src/Tqdev/PhpCrudApi/OpenApi/OpenApiColumnsBuilder.php
Expand Up @@ -39,8 +39,8 @@ public function build() /*: void*/
$this->setComponentResponse();
$this->setComponentRequestBody();
$this->setComponentParameters();
foreach (array_keys($this->operations) as $index => $type) {
$this->setTag($index, $type);
foreach (array_keys($this->operations) as $type) {
$this->setTag($type);
}
}

Expand All @@ -66,13 +66,13 @@ private function setPaths() /*: void*/
if (strpos($path, '{column}')) {
$parameters[] = 'column';
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$type");
}
$this->openapi->set("paths|$path|$method|tags|0", "$type");
$this->openapi->set("paths|$path|$method|tags|", "$type");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$type");
if ("$operation-$type" == 'update-table') {
$this->openapi->set("paths|$path|$method|description", "rename table");
Expand Down Expand Up @@ -180,9 +180,8 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|column|required", true);
}

private function setTag(int $index, string $type) /*: void*/
private function setTag(string $type) /*: void*/
{
$this->openapi->set("tags|$index|name", "$type");
$this->openapi->set("tags|$index|description", "$type operations");
$this->openapi->set("tags|", ['name' => $type, 'description' => "$type operations"]);
}
}
5 changes: 4 additions & 1 deletion src/Tqdev/PhpCrudApi/OpenApi/OpenApiDefinition.php
Expand Up @@ -13,10 +13,13 @@ public function __construct(array $base)

public function set(string $path, $value) /*: void*/
{
$parts = explode('|', trim($path, '|'));
$parts = explode('|', $path);
$current = &$this->root;
while (count($parts) > 0) {
$part = array_shift($parts);
if ($part === '') {
$part = count($current);
}
if (!isset($current[$part])) {
$current[$part] = [];
}
Expand Down
15 changes: 7 additions & 8 deletions src/Tqdev/PhpCrudApi/OpenApi/OpenApiRecordsBuilder.php
Expand Up @@ -89,8 +89,8 @@ public function build() /*: void*/
$this->setComponentRequestBody($tableName);
}
$this->setComponentParameters();
foreach ($tableNames as $index => $tableName) {
$this->setTag($index, $tableName);
foreach ($tableNames as $tableName) {
$this->setTag($tableName);
}
}

Expand Down Expand Up @@ -143,13 +143,13 @@ private function setPath(string $tableName) /*: void*/
$parameters = ['pk'];
}
}
foreach ($parameters as $p => $parameter) {
$this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
foreach ($parameters as $parameter) {
$this->openapi->set("paths|$path|$method|parameters||\$ref", "#/components/parameters/$parameter");
}
if (in_array($operation, ['create', 'update', 'increment'])) {
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-$normalizedTableName");
}
$this->openapi->set("paths|$path|$method|tags|0", "$tableName");
$this->openapi->set("paths|$path|$method|tags|", "$tableName");
$this->openapi->set("paths|$path|$method|operationId", "$operation" . "_" . "$normalizedTableName");
$this->openapi->set("paths|$path|$method|description", "$operation $tableName");
switch ($operation) {
Expand Down Expand Up @@ -375,9 +375,8 @@ private function setComponentParameters() /*: void*/
$this->openapi->set("components|parameters|join|required", false);
}

private function setTag(int $index, string $tableName) /*: void*/
private function setTag(string $tableName) /*: void*/
{
$this->openapi->set("tags|$index|name", "$tableName");
$this->openapi->set("tags|$index|description", "$tableName operations");
$this->openapi->set("tags|", ['name' => $tableName, 'description' => "$tableName operations"]);
}
}

0 comments on commit 3051700

Please sign in to comment.