Skip to content

Commit

Permalink
feat(type): Support numeric
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Jan 8, 2024
1 parent a6dc75d commit bc83813
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/OpenApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private static function resolveIdentifier(string $context, array $definitions, s
"negative-int" => new OpenApiType(type: "integer", format: "int64", maximum: -1),
"non-positive-int" => new OpenApiType(type: "integer", format: "int64", maximum: 0),
"bool", "boolean", "true", "false" => new OpenApiType(type: "boolean"),
"numeric" => new OpenApiType(type: "number"),
"double" => new OpenApiType(type: "number", format: "double"),
"float" => new OpenApiType(type: "number", format: "float"),
"mixed", "empty", "array" => new OpenApiType(type: "object"),
Expand Down
1 change: 1 addition & 0 deletions tests/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
['name' => 'Settings#booleanParameterRequired', 'url' => '/api/{apiVersion}/boolean', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#booleanParameterDefaultFalse', 'url' => '/api/{apiVersion}/boolean-false', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#booleanParameterDefaultTrue', 'url' => '/api/{apiVersion}/boolean-true', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#numericParameter', 'url' => '/api/{apiVersion}/numeric', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
],
];
12 changes: 12 additions & 0 deletions tests/lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,16 @@ public function booleanParameterDefaultFalse(bool $yesOrNo = false): DataRespons
public function booleanParameterDefaultTrue(bool $yesOrNo = true): DataResponse {
return new DataResponse();
}

/**
* A route with numeric
*
* @param numeric $value Some numeric value
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: Admin settings updated
*/
public function numericParameter(mixed $value): DataResponse {
return new DataResponse();
}
}
81 changes: 81 additions & 0 deletions tests/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,87 @@
}
}
}
},
"/ocs/v2.php/apps/notifications/api/{apiVersion}/numeric": {
"post": {
"operationId": "settings-numeric-parameter",
"summary": "A route with numeric",
"description": "This endpoint requires admin access",
"tags": [
"settings"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "value",
"in": "query",
"description": "Some numeric value",
"required": true,
"schema": {
"type": "number"
}
},
{
"name": "apiVersion",
"in": "path",
"required": true,
"schema": {
"type": "string",
"enum": [
"v2"
],
"default": "v2"
}
},
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "Admin settings updated",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
}
}
}
}
}
}
}
}
}
}
},
"tags": []
Expand Down

0 comments on commit bc83813

Please sign in to comment.