Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(type): Support numeric #64

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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