|
@@ -3768,11 +3768,22 @@ class OpenApiBuilder
|
3768
|
3768
|
if (!$this->isOperationOnTableAllowed($operation, $tableName)) {
|
3769
|
3769
|
continue;
|
3770
|
3770
|
}
|
|
3771
|
+ $parameters = [];
|
3771
|
3772
|
if (in_array($operation, ['list', 'create'])) {
|
3772
|
3773
|
$path = sprintf('/records/%s', $tableName);
|
|
3774
|
+ if ($operation == 'list') {
|
|
3775
|
+ $parameters = ['filter', 'include', 'exclude', 'order', 'size', 'page', 'join'];
|
|
3776
|
+ }
|
3773
|
3777
|
} else {
|
3774
|
3778
|
$path = sprintf('/records/%s/{%s}', $tableName, $pkName);
|
3775
|
|
- $this->openapi->set("paths|$path|$method|parameters|0|\$ref", "#/components/parameters/pk");
|
|
3779
|
+ if ($operation == 'read') {
|
|
3780
|
+ $parameters = ['pk', 'include', 'exclude', 'join'];
|
|
3781
|
+ } else {
|
|
3782
|
+ $parameters = ['pk'];
|
|
3783
|
+ }
|
|
3784
|
+ }
|
|
3785
|
+ foreach ($parameters as $p => $parameter) {
|
|
3786
|
+ $this->openapi->set("paths|$path|$method|parameters|$p|\$ref", "#/components/parameters/$parameter");
|
3776
|
3787
|
}
|
3777
|
3788
|
if (in_array($operation, ['create', 'update', 'increment'])) {
|
3778
|
3789
|
$this->openapi->set("paths|$path|$method|requestBody|\$ref", "#/components/requestBodies/$operation-" . urlencode($tableName));
|
|
@@ -3893,6 +3904,54 @@ class OpenApiBuilder
|
3893
|
3904
|
$this->openapi->set("components|parameters|pk|schema|type", "string");
|
3894
|
3905
|
$this->openapi->set("components|parameters|pk|description", "primary key value");
|
3895
|
3906
|
$this->openapi->set("components|parameters|pk|required", true);
|
|
3907
|
+
|
|
3908
|
+ $this->openapi->set("components|parameters|filter|name", "filter");
|
|
3909
|
+ $this->openapi->set("components|parameters|filter|in", "query");
|
|
3910
|
+ $this->openapi->set("components|parameters|filter|schema|type", "array");
|
|
3911
|
+ $this->openapi->set("components|parameters|filter|schema|items|type", "string");
|
|
3912
|
+ $this->openapi->set("components|parameters|filter|description", "Filters to be applied. Each filter consists of a column, an operator and a value (comma separated). Example: id,eq,1");
|
|
3913
|
+ $this->openapi->set("components|parameters|filter|required", false);
|
|
3914
|
+ $this->openapi->set("components|parameters|filter|explode", false);
|
|
3915
|
+
|
|
3916
|
+ $this->openapi->set("components|parameters|include|name", "include");
|
|
3917
|
+ $this->openapi->set("components|parameters|include|in", "query");
|
|
3918
|
+ $this->openapi->set("components|parameters|include|schema|type", "string");
|
|
3919
|
+ $this->openapi->set("components|parameters|include|description", "Columns you want to include in the output (comma separated). Example: posts.*,categories.name");
|
|
3920
|
+ $this->openapi->set("components|parameters|include|required", false);
|
|
3921
|
+
|
|
3922
|
+ $this->openapi->set("components|parameters|exclude|name", "exclude");
|
|
3923
|
+ $this->openapi->set("components|parameters|exclude|in", "query");
|
|
3924
|
+ $this->openapi->set("components|parameters|exclude|schema|type", "string");
|
|
3925
|
+ $this->openapi->set("components|parameters|exclude|description", "Columns you want to exclude from the output (comma separated). Example: posts.content");
|
|
3926
|
+ $this->openapi->set("components|parameters|exclude|required", false);
|
|
3927
|
+
|
|
3928
|
+ $this->openapi->set("components|parameters|order|name", "order");
|
|
3929
|
+ $this->openapi->set("components|parameters|order|in", "query");
|
|
3930
|
+ $this->openapi->set("components|parameters|order|schema|type", "array");
|
|
3931
|
+ $this->openapi->set("components|parameters|order|schema|items|type", "string");
|
|
3932
|
+ $this->openapi->set("components|parameters|order|description", "Column you want to sort on and the sort direction (comma separated). Example: id,desc");
|
|
3933
|
+ $this->openapi->set("components|parameters|order|required", false);
|
|
3934
|
+ $this->openapi->set("components|parameters|order|explode", false);
|
|
3935
|
+
|
|
3936
|
+ $this->openapi->set("components|parameters|size|name", "size");
|
|
3937
|
+ $this->openapi->set("components|parameters|size|in", "query");
|
|
3938
|
+ $this->openapi->set("components|parameters|size|schema|type", "string");
|
|
3939
|
+ $this->openapi->set("components|parameters|size|description", "Maximum number of results (for top lists). Example: 10");
|
|
3940
|
+ $this->openapi->set("components|parameters|size|required", false);
|
|
3941
|
+
|
|
3942
|
+ $this->openapi->set("components|parameters|page|name", "page");
|
|
3943
|
+ $this->openapi->set("components|parameters|page|in", "query");
|
|
3944
|
+ $this->openapi->set("components|parameters|page|schema|type", "string");
|
|
3945
|
+ $this->openapi->set("components|parameters|page|description", "Page number and page size (comma separated). Example: 1,10");
|
|
3946
|
+ $this->openapi->set("components|parameters|page|required", false);
|
|
3947
|
+
|
|
3948
|
+ $this->openapi->set("components|parameters|join|name", "join");
|
|
3949
|
+ $this->openapi->set("components|parameters|join|in", "query");
|
|
3950
|
+ $this->openapi->set("components|parameters|join|schema|type", "array");
|
|
3951
|
+ $this->openapi->set("components|parameters|join|schema|items|type", "string");
|
|
3952
|
+ $this->openapi->set("components|parameters|join|description", "Paths (comma separated) to related entities that you want to include. Example: comments,users");
|
|
3953
|
+ $this->openapi->set("components|parameters|join|required", false);
|
|
3954
|
+ $this->openapi->set("components|parameters|join|explode", false);
|
3896
|
3955
|
}
|
3897
|
3956
|
|
3898
|
3957
|
private function setTag(int $index, String $tableName) /*: void*/
|