diff --git a/generate-spec b/generate-spec index a66d8a4..147358c 100755 --- a/generate-spec +++ b/generate-spec @@ -297,9 +297,24 @@ foreach ($parsedRoutes as $key => $value) { Logger::error($routeName, "Controller '" . $controllerName . "' not found"); continue; } + + $controllerScopes = Helpers::getOpenAPIAttributeScopes($controllerClass, $routeName); if (Helpers::classMethodHasAnnotationOrAttribute($controllerClass, "IgnoreOpenAPI")) { - Logger::debug($routeName, "Controller '" . $controllerName . "' ignored because of IgnoreOpenAPI attribute"); - continue; + if (count($controllerScopes) === 0 || (in_array('ignore', $controllerScopes, true) && count($controllerScopes) === 1)) { + Logger::info($routeName, "Controller '" . $controllerName . "' ignored because of IgnoreOpenAPI attribute"); + continue; + } + + Logger::panic($routeName, "Controller '" . $controllerName . "' is marked as ignore but also has other scopes"); + } + + if (in_array('ignore', $controllerScopes, true)) { + if (count($controllerScopes) === 1) { + Logger::info($routeName, "Controller '" . $controllerName . "' ignored because of OpenAPI attribute"); + continue; + } + + Logger::panic($routeName, "Controller '" . $controllerName . "' is marked as ignore but also has other scopes"); } $tagName = implode("_", array_map(fn (string $s) => strtolower($s), Helpers::splitOnUppercaseFollowedByNonUppercase($controllerName))); @@ -349,12 +364,38 @@ foreach ($parsedRoutes as $key => $value) { $isAdmin = !Helpers::classMethodHasAnnotationOrAttribute($methodFunction, "NoAdminRequired") && !$isPublic; $isDeprecated = Helpers::classMethodHasAnnotationOrAttribute($methodFunction, "deprecated"); $isIgnored = Helpers::classMethodHasAnnotationOrAttribute($methodFunction, "IgnoreOpenAPI"); + $scopes = Helpers::getOpenAPIAttributeScopes($classMethod, $routeName); if ($isIgnored) { - Logger::debug($routeName, "Route ignored because of IgnoreOpenAPI attribute"); - continue; + if (count($scopes) === 0 || (in_array('ignore', $scopes, true) && count($scopes) === 1)) { + Logger::debug($routeName, "Route ignored because of IgnoreOpenAPI attribute"); + continue; + } + + Logger::panic($routeName, "Route is marked as ignore but also has other scopes"); } + if (in_array('ignore', $scopes, true)) { + if (count($scopes) === 1) { + Logger::info($routeName, "Route ignored because of OpenAPI attribute"); + continue; + } + + Logger::panic($routeName, "Route is marked as ignore but also has other scopes"); + } + + if (empty($scopes)) { + if (!empty($controllerScopes)) { + $scopes = $controllerScopes; + } elseif ($isAdmin) { + $scopes = ['administration']; + } else { + $scopes = ['default']; + } + } + + $routeTags = Helpers::getOpenAPIAttributeTagsByScope($classMethod, $routeName, $tagName, reset($scopes)); + if ($isOCS && !array_key_exists("OCSMeta", $schemas)) { $schemas["OCSMeta"] = [ "type" => "object", @@ -402,21 +443,24 @@ foreach ($parsedRoutes as $key => $value) { continue; } - $routes[] = new Route( - $routeName, - $tagName, - $methodName, - $postfix, - $verb, - $url, - $requirements, - $defaults, - $classMethodInfo, - $isOCS, - $isCORS, - $isCSRFRequired, - $isPublic, - ); + foreach ($scopes as $scope) { + $routes[$scope] ??= []; + $routes[$scope][] = new Route( + $routeName, + $routeTags[$scope] ?? [$tagName], + $methodName, + $postfix, + $verb, + $url, + $requirements, + $defaults, + $classMethodInfo, + $isOCS, + $isCORS, + $isCSRFRequired, + $isPublic, + ); + } Logger::debug($routeName, "Route generated"); } @@ -424,228 +468,240 @@ foreach ($parsedRoutes as $key => $value) { $tagNames = []; if ($useTags) { - foreach ($routes as $route) { - if (!in_array($route->tag, $tagNames)) { - $tagNames[] = $route->tag; + foreach ($routes as $scope => $scopeRoutes) { + foreach ($scopeRoutes as $route) { + foreach ($route->tags as $tag) { + if (!in_array($tag, $tagNames)) { + $tagNames[] = $tag; + } + } } } } -foreach ($routes as $route) { - $pathParameters = []; - $urlParameters = []; - - preg_match_all("/{[^}]*}/", $route->url, $urlParameters); - $urlParameters = array_map(fn (string $name) => substr($name, 1, -1), $urlParameters[0]); - - foreach ($urlParameters as $urlParameter) { - $matchingParameters = array_filter($route->controllerMethod->parameters, function (ControllerMethodParameter $param) use ($urlParameter) { - return $param->name == $urlParameter; - }); - $requirement = array_key_exists($urlParameter, $route->requirements) ? $route->requirements[$urlParameter] : null; - if (count($matchingParameters) == 1) { - $parameter = $matchingParameters[array_keys($matchingParameters)[0]]; - if ($parameter?->methodParameter == null && ($route->requirements == null || !array_key_exists($urlParameter, $route->requirements))) { - Logger::error($route->name, "Unable to find parameter for '" . $urlParameter . "'"); - continue; - } - - $schema = $parameter->type->toArray($openapiVersion, true); - $description = $parameter?->docType != null && $parameter->docType->description != "" ? Helpers::cleanDocComment($parameter->docType->description) : null; - } else { - $schema = [ - "type" => "string", - ]; - $description = null; - } +$scopePaths = []; + +foreach ($routes as $scope => $scopeRoutes) { + foreach ($scopeRoutes as $route) { + $pathParameters = []; + $urlParameters = []; + + preg_match_all("/{[^}]*}/", $route->url, $urlParameters); + $urlParameters = array_map(fn (string $name) => substr($name, 1, -1), $urlParameters[0]); + + foreach ($urlParameters as $urlParameter) { + $matchingParameters = array_filter($route->controllerMethod->parameters, function (ControllerMethodParameter $param) use ($urlParameter) { + return $param->name == $urlParameter; + }); + $requirement = array_key_exists($urlParameter, $route->requirements) ? $route->requirements[$urlParameter] : null; + if (count($matchingParameters) == 1) { + $parameter = $matchingParameters[array_keys($matchingParameters)[0]]; + if ($parameter?->methodParameter == null && ($route->requirements == null || !array_key_exists($urlParameter, $route->requirements))) { + Logger::error($route->name, "Unable to find parameter for '" . $urlParameter . "'"); + continue; + } - if ($requirement != null) { - if (!str_starts_with($requirement, "^")) { - $requirement = "^" . $requirement; - } - if (!str_ends_with($requirement, "$")) { - $requirement = $requirement . "$"; + $schema = $parameter->type->toArray($openapiVersion, true); + $description = $parameter?->docType != null && $parameter->docType->description != "" ? Helpers::cleanDocComment($parameter->docType->description) : null; + } else { + $schema = [ + "type" => "string", + ]; + $description = null; } - } - if ($schema["type"] == "string") { - if ($urlParameter == "apiVersion") { - if ($requirement == null) { - Logger::error($route->name, "Missing requirement for apiVersion"); - continue; + if ($requirement != null) { + if (!str_starts_with($requirement, "^")) { + $requirement = "^" . $requirement; } - preg_match("/^\^\(([v0-9-.|]*)\)\\$$/m", $requirement, $matches); - if (count($matches) == 2) { - $enum = explode("|", $matches[1]); - } else { - Logger::error($route->name, "Invalid requirement for apiVersion"); - continue; + if (!str_ends_with($requirement, "$")) { + $requirement = $requirement . "$"; } - $schema["enum"] = $enum; - $schema["default"] = end($enum); - } elseif ($requirement != null) { - $schema["pattern"] = $requirement; } - } - - if (array_key_exists($urlParameter, $route->defaults)) { - $schema["default"] = $route->defaults[$urlParameter]; - } - $pathParameters[] = array_merge( - [ - "name" => $urlParameter, - "in" => "path", - ], - $description != null ? ["description" => $description] : [], - [ - "required" => true, - "schema" => $schema, - ], - ); - } + if ($schema["type"] == "string") { + if ($urlParameter == "apiVersion") { + if ($requirement == null) { + Logger::error($route->name, "Missing requirement for apiVersion"); + continue; + } + preg_match("/^\^\(([v0-9-.|]*)\)\\$$/m", $requirement, $matches); + if (count($matches) == 2) { + $enum = explode("|", $matches[1]); + } else { + Logger::error($route->name, "Invalid requirement for apiVersion"); + continue; + } + $schema["enum"] = $enum; + $schema["default"] = end($enum); + } elseif ($requirement != null) { + $schema["pattern"] = $requirement; + } + } - $queryParameters = []; - foreach ($route->controllerMethod->parameters as $parameter) { - $alreadyInPath = false; - foreach ($pathParameters as $pathParameter) { - if ($pathParameter["name"] == $parameter->name) { - $alreadyInPath = true; - break; + if (array_key_exists($urlParameter, $route->defaults)) { + $schema["default"] = $route->defaults[$urlParameter]; } - } - if (!$alreadyInPath) { - $queryParameters[] = $parameter; - } - } - $mergedResponses = []; - foreach (array_unique(array_map(fn (ControllerMethodResponse $response) => $response->statusCode, array_filter($route->controllerMethod->responses, fn (?ControllerMethodResponse $response) => $response != null))) as $statusCode) { - if ($firstStatusCode && count($mergedResponses) > 0) { - break; + $pathParameters[] = array_merge( + [ + "name" => $urlParameter, + "in" => "path", + ], + $description != null ? ["description" => $description] : [], + [ + "required" => true, + "schema" => $schema, + ], + ); } - $statusCodeResponses = array_filter($route->controllerMethod->responses, fn (?ControllerMethodResponse $response) => $response != null && $response->statusCode == $statusCode); - $headers = []; - foreach ($statusCodeResponses as $response) { - if ($response->headers !== null) { - $headers = array_merge($headers, $response->headers); + $queryParameters = []; + foreach ($route->controllerMethod->parameters as $parameter) { + $alreadyInPath = false; + foreach ($pathParameters as $pathParameter) { + if ($pathParameter["name"] == $parameter->name) { + $alreadyInPath = true; + break; + } + } + if (!$alreadyInPath) { + $queryParameters[] = $parameter; } } - $mergedContentTypeResponses = []; - foreach (array_unique(array_map(fn (ControllerMethodResponse $response) => $response->contentType, array_filter($statusCodeResponses, fn (ControllerMethodResponse $response) => $response->contentType != null))) as $contentType) { - if ($firstContentType && count($mergedContentTypeResponses) > 0) { + $mergedResponses = []; + foreach (array_unique(array_map(fn (ControllerMethodResponse $response) => $response->statusCode, array_filter($route->controllerMethod->responses, fn (?ControllerMethodResponse $response) => $response != null))) as $statusCode) { + if ($firstStatusCode && count($mergedResponses) > 0) { break; } - /** @var ControllerMethodResponse[] $contentTypeResponses */ - $contentTypeResponses = array_values(array_filter($statusCodeResponses, fn (ControllerMethodResponse $response) => $response->contentType == $contentType)); + $statusCodeResponses = array_filter($route->controllerMethod->responses, fn (?ControllerMethodResponse $response) => $response != null && $response->statusCode == $statusCode); + $headers = []; + foreach ($statusCodeResponses as $response) { + if ($response->headers !== null) { + $headers = array_merge($headers, $response->headers); + } + } - $hasEmpty = count(array_filter($contentTypeResponses, fn (ControllerMethodResponse $response) => $response->type == null)) > 0; - $uniqueResponses = array_values(array_intersect_key($contentTypeResponses, array_unique(array_map(fn (ControllerMethodResponse $response) => $response->type->toArray($openapiVersion), array_filter($contentTypeResponses, fn (ControllerMethodResponse $response) => $response->type != null)), SORT_REGULAR))); - if (count($uniqueResponses) == 1) { - if ($hasEmpty) { - $mergedContentTypeResponses[$contentType] = []; + $mergedContentTypeResponses = []; + foreach (array_unique(array_map(fn (ControllerMethodResponse $response) => $response->contentType, array_filter($statusCodeResponses, fn (ControllerMethodResponse $response) => $response->contentType != null))) as $contentType) { + if ($firstContentType && count($mergedContentTypeResponses) > 0) { + break; + } + + /** @var ControllerMethodResponse[] $contentTypeResponses */ + $contentTypeResponses = array_values(array_filter($statusCodeResponses, fn (ControllerMethodResponse $response) => $response->contentType == $contentType)); + + $hasEmpty = count(array_filter($contentTypeResponses, fn (ControllerMethodResponse $response) => $response->type == null)) > 0; + $uniqueResponses = array_values(array_intersect_key($contentTypeResponses, array_unique(array_map(fn (ControllerMethodResponse $response) => $response->type->toArray($openapiVersion), array_filter($contentTypeResponses, fn (ControllerMethodResponse $response) => $response->type != null)), SORT_REGULAR))); + if (count($uniqueResponses) == 1) { + if ($hasEmpty) { + $mergedContentTypeResponses[$contentType] = []; + } else { + $schema = Helpers::cleanEmptyResponseArray($contentTypeResponses[0]->type->toArray($openapiVersion)); + $mergedContentTypeResponses[$contentType] = ["schema" => Helpers::wrapOCSResponse($route, $contentTypeResponses[0], $schema)]; + } } else { - $schema = Helpers::cleanEmptyResponseArray($contentTypeResponses[0]->type->toArray($openapiVersion)); - $mergedContentTypeResponses[$contentType] = ["schema" => Helpers::wrapOCSResponse($route, $contentTypeResponses[0], $schema)]; + $mergedContentTypeResponses[$contentType] = [ + "schema" => [ + [$hasEmpty ? "anyOf" : "oneOf" => array_map(function (ControllerMethodResponse $response) use ($route, $openapiVersion) { + $schema = Helpers::cleanEmptyResponseArray($response->type->toArray($openapiVersion)); + return Helpers::wrapOCSResponse($route, $response, $schema); + }, $uniqueResponses)], + ], + ]; } - } else { - $mergedContentTypeResponses[$contentType] = [ - "schema" => [ - [$hasEmpty ? "anyOf" : "oneOf" => array_map(function (ControllerMethodResponse $response) use ($route, $openapiVersion) { - $schema = Helpers::cleanEmptyResponseArray($response->type->toArray($openapiVersion)); - return Helpers::wrapOCSResponse($route, $response, $schema); - }, $uniqueResponses)], - ], - ]; } - } - $mergedResponses[$statusCode] = array_merge( - [ - "description" => array_key_exists($statusCode, $route->controllerMethod->responseDescription) ? $route->controllerMethod->responseDescription[$statusCode] : "", - ], - count($headers) > 0 ? [ - "headers" => array_combine( - array_keys($headers), - array_map( - fn (OpenApiType $type) => [ - "schema" => $type->toArray($openapiVersion), - ], - array_values($headers), + $mergedResponses[$statusCode] = array_merge( + [ + "description" => array_key_exists($statusCode, $route->controllerMethod->responseDescription) ? $route->controllerMethod->responseDescription[$statusCode] : "", + ], + count($headers) > 0 ? [ + "headers" => array_combine( + array_keys($headers), + array_map( + fn (OpenApiType $type) => [ + "schema" => $type->toArray($openapiVersion), + ], + array_values($headers), + ), ), + ] : [], + count($mergedContentTypeResponses) > 0 ? [ + "content" => $mergedContentTypeResponses, + ] : [], + ); + } + + $operationId = [...$route->tags, ...Helpers::splitOnUppercaseFollowedByNonUppercase($route->methodName)]; + if ($route->postfix != null) { + $operationId[] = $route->postfix; + } + + $security = []; + if ($route->isPublic) { + // Add empty authentication, meaning that it's optional. We can't know if there is a difference in behaviour for authenticated vs. unauthenticated access on public pages (e.g. capabilities) + $security[] = new stdClass(); + } + if (!$route->isCORS) { + // Bearer auth is not allowed on CORS routes + $security[] = ["bearer_auth" => []]; + } + if (!$route->isCSRFRequired || $route->isOCS) { + // Add basic auth last, so it's only fallback if bearer is available + $security[] = ["basic_auth" => []]; + } + + $operation = array_merge( + ["operationId" => strtolower(implode("-", $operationId))], + $route->controllerMethod->summary != null ? ["summary" => $route->controllerMethod->summary] : [], + count($route->controllerMethod->description) > 0 ? ["description" => implode("\n", $route->controllerMethod->description)] : [], + $route->controllerMethod->isDeprecated ? ["deprecated" => true] : [], + $useTags ? ["tags" => $route->tags] : [], + count($security) > 0 ? ["security" => $security] : [], + count($queryParameters) > 0 || count($pathParameters) > 0 || $route->isOCS ? [ + "parameters" => array_merge( + array_map(fn (ControllerMethodParameter $parameter) => array_merge( + [ + "name" => $parameter->name . ($parameter->type->type == "array" ? "[]" : ""), + "in" => "query", + ], + $parameter->docType != null && $parameter->docType->description != "" ? ["description" => Helpers::cleanDocComment($parameter->docType->description)] : [], + !$parameter->type->nullable && !$parameter->type->hasDefaultValue ? ["required" => true] : [], + ["schema" => $parameter->type->toArray($openapiVersion, true),], + ), $queryParameters), + $pathParameters, + $route->isOCS ? [[ + "name" => "OCS-APIRequest", + "in" => "header", + "description" => "Required to be true for the API request to pass", + "required" => true, + "schema" => [ + "type" => "boolean", + "default" => true, + ], + ]] : [], ), ] : [], - count($mergedContentTypeResponses) > 0 ? [ - "content" => $mergedContentTypeResponses, - ] : [], + ["responses" => $mergedResponses], ); - } - $operationId = [$route->tag, ...Helpers::splitOnUppercaseFollowedByNonUppercase($route->methodName)]; - if ($route->postfix != null) { - $operationId[] = $route->postfix; - } + $scopePaths[$scope] ??= []; + $scopePaths[$scope][$route->url] ??= []; - $security = []; - if ($route->isPublic) { - // Add empty authentication, meaning that it's optional. We can't know if there is a difference in behaviour for authenticated vs. unauthenticated access on public pages (e.g. capabilities) - $security[] = new stdClass(); - } - if (!$route->isCORS) { - // Bearer auth is not allowed on CORS routes - $security[] = ["bearer_auth" => []]; - } - if (!$route->isCSRFRequired || $route->isOCS) { - // Add basic auth last, so it's only fallback if bearer is available - $security[] = ["basic_auth" => []]; - } + if (!array_key_exists($route->url, $openapi["paths"])) { + $openapi["paths"][$route->url] = []; + } - $operation = array_merge( - ["operationId" => strtolower(implode("-", $operationId))], - $route->controllerMethod->summary != null ? ["summary" => $route->controllerMethod->summary] : [], - count($route->controllerMethod->description) > 0 ? ["description" => implode("\n", $route->controllerMethod->description)] : [], - $route->controllerMethod->isDeprecated ? ["deprecated" => true] : [], - $useTags ? ["tags" => [$route->tag]] : [], - count($security) > 0 ? ["security" => $security] : [], - count($queryParameters) > 0 || count($pathParameters) > 0 || $route->isOCS ? [ - "parameters" => array_merge( - array_map(fn (ControllerMethodParameter $parameter) => array_merge( - [ - "name" => $parameter->name . ($parameter->type->type == "array" ? "[]" : ""), - "in" => "query", - ], - $parameter->docType != null && $parameter->docType->description != "" ? ["description" => Helpers::cleanDocComment($parameter->docType->description)] : [], - !$parameter->type->nullable && !$parameter->type->hasDefaultValue ? ["required" => true] : [], - ["schema" => $parameter->type->toArray($openapiVersion, true),], - ), $queryParameters), - $pathParameters, - $route->isOCS ? [[ - "name" => "OCS-APIRequest", - "in" => "header", - "description" => "Required to be true for the API request to pass", - "required" => true, - "schema" => [ - "type" => "boolean", - "default" => true, - ], - ]] : [], - ), - ] : [], - ["responses" => $mergedResponses], - ); - if (!array_key_exists($route->url, $openapi["paths"])) { - $openapi["paths"][$route->url] = []; - } + $verb = strtolower($route->verb); + if (array_key_exists($verb, $scopePaths[$scope][$route->url])) { + Logger::error($route->name, "Operation '" . $route->verb . "' already set for path '" . $route->url . "'"); + } - $verb = strtolower($route->verb); - if (array_key_exists($verb, $openapi["paths"][$route->url])) { - Logger::error($route->name, "Operation '" . $route->verb . "' already set for path '" . $route->url . "'"); + $scopePaths[$scope][$route->url][$verb] = $operation; } - - $openapi["paths"][$route->url][$verb] = $operation; } if ($appIsCore) { @@ -688,7 +744,7 @@ if ($appIsCore) { ], ], ]; - $openapi["paths"]["/status.php"] = [ + $scopePaths['default']['/status.php'] = [ "get" => [ "operationId" => "get-status", "responses" => [ @@ -711,17 +767,106 @@ if (count($schemas) == 0 && count($routes) == 0) { Logger::error("app", "No spec generated"); } -if (count($openapi["paths"]) == 0) { - $openapi["paths"] = new stdClass(); -} - ksort($schemas); -$openapi["components"]["schemas"] = count($schemas) == 0 ? new stdClass() : $schemas; if ($useTags) { $openapi["tags"] = $tags; } -file_put_contents($out, json_encode($openapi, Helpers::jsonFlags())); +$hasSingleScope = count($scopePaths) <= 1; +$fullScopePathArrays = []; + +if (!$hasSingleScope) { + $scopePaths['full'] = []; +} + +foreach ($scopePaths as $scope => $paths) { + $openapiScope = $openapi; + + $scopeSuffix = ($hasSingleScope || $scope === 'default') ? '' : '-' . $scope; + $openapiScope['info']['title'] .= $scopeSuffix; + $openapiScope['paths'] = $paths; + + if ($scope !== 'full' && !$hasSingleScope) { + $fullScopePathArrays[] = $paths; + } + + if ($scope === 'full') { + $openapiScope['paths'] = array_merge(...$fullScopePathArrays); + $openapiScope['components']['schemas'] = $schemas; + } else { + $usedSchemas = []; + foreach ($paths as $url => $urlRoutes) { + foreach ($urlRoutes as $httpMethod => $routeData) { + foreach ($routeData['responses'] as $statusCode => $responseData) { + if (empty($responseData['content'])) { + continue; + } + + foreach ($responseData['content'] as $contentType => $contentData) { + if (isset($contentData['schema']) && is_array($contentData['schema'])) { + $newSchemas = Helpers::collectUsedRefs($contentData['schema']); + $usedSchemas = array_merge($usedSchemas, $newSchemas); + } + } + } + } + } + + $scopedSchemas = []; + while ($usedSchema = array_shift($usedSchemas)) { + if (!str_starts_with($usedSchema, '#/components/schemas/')) { + continue; + } + + $schemaName = substr($usedSchema, strlen('#/components/schemas/')); + + if (!isset($schemas[$schemaName])) { + Logger::error("app", "Schema $schemaName used by scope $scope is not defined"); + } + + $newRefs = Helpers::collectUsedRefs($schemas[$schemaName]); + foreach ($newRefs as $newRef) { + if (!isset($scopedSchemas[substr($newRef, strlen('#/components/schemas/'))])) { + $usedSchemas[] = $newRef; + } + } + + $scopedSchemas[$schemaName] = $schemas[$schemaName]; + } -Logger::info("app", "Generated ". count($routes). " routes!"); + if (isset($schemas['Capabilities'])) { + $scopedSchemas['Capabilities'] = $schemas['Capabilities']; + } + if (isset($schemas['PublicCapabilities'])) { + $scopedSchemas['PublicCapabilities'] = $schemas['PublicCapabilities']; + } + + if (count($scopedSchemas) === 0) { + $scopedSchemas = new \stdClass(); + } + + $openapiScope['components']['schemas'] = $scopedSchemas; + } + + $pathsCount = count($openapiScope['paths']); + if ($pathsCount === 0) { + // Make sure the paths array is always a dictionary + $openapiScope['paths'] = new \stdClass(); + } + + $startExtension = strrpos($out, '.'); + if ($startExtension !== false) { + // Path + filename (without extension) + $path = substr($out, 0, $startExtension); + // Extension + $extension = substr($out, $startExtension); + $scopeOut = $path . $scopeSuffix . $extension; + } else { + $scopeOut = $out . $scopeSuffix; + } + + file_put_contents($scopeOut, json_encode($openapiScope, Helpers::jsonFlags())); + + Logger::info('app', 'Generated scope ' . $scope . ' with ' . $pathsCount . ' routes!'); +} diff --git a/src/Helpers.php b/src/Helpers.php index f4076d1..2dd7496 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -4,11 +4,18 @@ use Exception; use PhpParser\Node; +use PhpParser\Node\Arg; +use PhpParser\Node\AttributeGroup; +use PhpParser\Node\Expr\Array_; +use PhpParser\Node\Expr\ClassConstFetch; +use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use stdClass; class Helpers { + public const OPENAPI_ATTRIBUTE_CLASSNAME = 'OpenAPI'; + public static function generateReadableAppID(string $appID): string { return implode("", array_map(fn (string $s) => ucfirst($s), explode("_", $appID))); } @@ -133,7 +140,7 @@ public static function classMethodHasAnnotationOrAttribute(ClassMethod|Class_|No return true; } - /** @var Node\AttributeGroup $attrGroup */ + /** @var AttributeGroup $attrGroup */ foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { if ($attr->name->getLast() == $annotation) { @@ -149,4 +156,122 @@ public static function cleanSchemaName(string $name): string { global $readableAppID; return substr($name, strlen($readableAppID)); } + + protected static function getScopeNameFromAttributeArgument(Arg $arg, int $key, string $routeName): ?string { + if ($arg->name?->name === 'scope' || ($arg->name === null && $key === 0)) { + if ($arg->value instanceof ClassConstFetch) { + if ($arg->value->class->getLast() === self::OPENAPI_ATTRIBUTE_CLASSNAME) { + return self::getScopeNameFromConst($arg->value); + } + } elseif ($arg->value instanceof String_) { + return $arg->value->value; + } else { + Logger::panic($routeName, 'Can not interpret value of scope provided in OpenAPI(scope: …) attribute. Please use string or OpenAPI::SCOPE_* constants'); + } + } + + return null; + } + + protected static function getScopeNameFromConst(ClassConstFetch $scope): string { + return match ($scope->name->name) { + 'SCOPE_DEFAULT' => 'default', + 'SCOPE_ADMINISTRATION' => 'administration', + 'SCOPE_FEDERATION' => 'federation', + 'SCOPE_IGNORE' => 'ignore', + // Fall back for future scopes assuming we follow the pattern (cut of 'SCOPE_' and lower case) + default => strtolower(substr($scope->name->name, 6)), + }; + } + + public static function getOpenAPIAttributeScopes(ClassMethod|Class_|Node $node, string $routeName): array { + $scopes = []; + + /** @var AttributeGroup $attrGroup */ + foreach ($node->attrGroups as $attrGroup) { + foreach ($attrGroup->attrs as $attr) { + if ($attr->name->getLast() === self::OPENAPI_ATTRIBUTE_CLASSNAME) { + if (empty($attr->args)) { + $scopes[] = 'default'; + continue; + } + + foreach ($attr->args as $key => $arg) { + $scope = self::getScopeNameFromAttributeArgument($arg, (int) $key, $routeName); + if ($scope !== null) { + $scopes[] = $scope; + } + } + } + } + } + + return $scopes; + } + + public static function getOpenAPIAttributeTagsByScope(ClassMethod|Class_|Node $node, string $routeName, string $defaultTag, string $defaultScope): array { + $tags = []; + + /** @var AttributeGroup $attrGroup */ + foreach ($node->attrGroups as $attrGroup) { + foreach ($attrGroup->attrs as $attr) { + if ($attr->name->getLast() === self::OPENAPI_ATTRIBUTE_CLASSNAME) { + if (empty($attr->args)) { + $tags[$defaultScope] = [$defaultTag]; + continue; + } + + $foundTags = []; + $foundScopeName = null; + foreach ($attr->args as $key => $arg) { + $foundScopeName = self::getScopeNameFromAttributeArgument($arg, (int) $key, $routeName); + + if ($arg->name?->name !== 'tags' && ($arg->name !== null || $key !== 1)) { + continue; + } + + if (!$arg->value instanceof Array_) { + Logger::panic($routeName, 'Can not read value of tags provided in OpenAPI attribute for route ' . $routeName); + } + + foreach ($arg->value->items as $item) { + if ($item?->value instanceof String_) { + $foundTags[] = $item->value->value; + } + } + } + + if (!empty($foundTags)) { + $tags[$foundScopeName ?: $defaultScope] = $foundTags; + } + } + } + } + + return $tags; + } + + public static function collectUsedRefs(array $data): array { + $refs = []; + if (isset($data['$ref'])) { + $refs[] = [$data['$ref']]; + } + + foreach (['allOf', 'oneOf', 'anyOf', 'properties', 'additionalProperties'] as $group) { + if (!isset($data[$group]) || !is_array($data[$group])) { + continue; + } + + foreach ($data[$group] as $property) { + if (is_array($property)) { + $refs[] = self::collectUsedRefs($property); + } + } + } + + if (isset($data['items'])) { + $refs[] = self::collectUsedRefs($data['items']); + } + return array_merge(...$refs); + } } diff --git a/src/Route.php b/src/Route.php index f53c72b..d0e064c 100644 --- a/src/Route.php +++ b/src/Route.php @@ -5,7 +5,7 @@ class Route { public function __construct( public string $name, - public string $tag, + public array $tags, public string $methodName, public ?string $postfix, public string $verb, diff --git a/tests/appinfo/routes.php b/tests/appinfo/routes.php index e17e0e6..7806088 100644 --- a/tests/appinfo/routes.php +++ b/tests/appinfo/routes.php @@ -29,11 +29,14 @@ ['name' => 'AdminSettings#adminScopeImplicitFromAdminRequired', 'url' => '/api/{apiVersion}/default-admin', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'AdminSettings#movedToDefaultScope', 'url' => '/api/{apiVersion}/default-admin-overwritten', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'AdminSettings#movedToSettingsTag', 'url' => '/api/{apiVersion}/moved-with-tag', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], + ['name' => 'AdminSettings#movedToSettingsTagUnnamed', 'url' => '/api/{apiVersion}/moved-with-unnamed-tag', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], + + ['name' => 'Federation#federationByController', 'url' => '/api/{apiVersion}/controller-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], + ['name' => 'Federation#movedToDefaultScope', 'url' => '/api/{apiVersion}/default-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], - ['name' => 'Settings#federationByController', 'url' => '/api/{apiVersion}/controller-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'Settings#ignoreByDeprecatedAttributeOnMethod', 'url' => '/api/{apiVersion}/ignore-openapi-attribute', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'Settings#ignoreByScopeOnMethod', 'url' => '/api/{apiVersion}/ignore-method-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], - ['name' => 'Settings#movedToDefaultScope', 'url' => '/api/{apiVersion}/default-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], + ['name' => 'Settings#ignoreByUnnamedScopeOnMethod', 'url' => '/api/{apiVersion}/ignore-method-scope-unnamed', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'Settings#movedToAdminScope', 'url' => '/api/{apiVersion}/admin-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'Settings#defaultAndAdminScope', 'url' => '/api/{apiVersion}/default-and-admin-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], ['name' => 'Settings#nestedSchemas', 'url' => '/api/{apiVersion}/nested-schemas', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']], diff --git a/tests/lib/Controller/AdminSettingsController.php b/tests/lib/Controller/AdminSettingsController.php index f3fbd72..b16a9cf 100644 --- a/tests/lib/Controller/AdminSettingsController.php +++ b/tests/lib/Controller/AdminSettingsController.php @@ -66,4 +66,16 @@ public function movedToDefaultScope(): DataResponse { public function movedToSettingsTag(): DataResponse { return new DataResponse(); } + + /** + * Route in default scope with tags but without named parameters on the attribute + * + * @return DataResponse, array{}> + * + * 200: Personal settings updated + */ + #[OpenAPI(OpenAPI::SCOPE_ADMINISTRATION, ['settings', 'admin-settings'])] + public function movedToSettingsTagUnnamed(): DataResponse { + return new DataResponse(); + } } diff --git a/tests/lib/Controller/FederationController.php b/tests/lib/Controller/FederationController.php new file mode 100644 index 0000000..a656530 --- /dev/null +++ b/tests/lib/Controller/FederationController.php @@ -0,0 +1,69 @@ + + * + * @author Julien Barnoin + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Notifications\Controller; + +use OCA\Notifications\ResponseDefinitions; +use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\OpenAPI; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; + +/** + * @psalm-import-type NotificationsPushDevice from ResponseDefinitions + * @psalm-import-type NotificationsNotification from ResponseDefinitions + * @psalm-import-type NotificationsCollection from ResponseDefinitions + */ +#[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)] +class FederationController extends OCSController { + + /** + * @NoAdminRequired + * + * Route is in federation scope as per controller scope + * + * @return DataResponse, array{}> + * + * 200: OK + */ + public function federationByController(): DataResponse { + return new DataResponse(); + } + + /** + * @NoAdminRequired + * + * Route is only in the default scope (moved from federation) + * + * @return DataResponse, array{}> + * + * 200: Personal settings updated + */ + #[OpenAPI] + public function movedToDefaultScope(): DataResponse { + return new DataResponse(); + } +} diff --git a/tests/lib/Controller/SettingsController.php b/tests/lib/Controller/SettingsController.php index 71f9878..28a76cd 100644 --- a/tests/lib/Controller/SettingsController.php +++ b/tests/lib/Controller/SettingsController.php @@ -38,22 +38,7 @@ * @psalm-import-type NotificationsNotification from ResponseDefinitions * @psalm-import-type NotificationsCollection from ResponseDefinitions */ -#[OpenAPI(scope: OpenAPI::SCOPE_FEDERATION)] class SettingsController extends OCSController { - - /** - * @NoAdminRequired - * - * Route is ignored because of scope on the controller - * - * @return DataResponse, array{}> - * - * 200: OK - */ - public function federationByController(): DataResponse { - return new DataResponse(); - } - /** * @NoAdminRequired * @@ -85,14 +70,14 @@ public function ignoreByScopeOnMethod(): DataResponse { /** * @NoAdminRequired * - * Route is only in the default scope + * Route is ignored because of scope on the method but without `scope: ` name * * @return DataResponse, array{}> * - * 200: Personal settings updated + * 200: OK */ - #[OpenAPI] - public function movedToDefaultScope(): DataResponse { + #[OpenAPI(OpenAPI::SCOPE_IGNORE)] + public function ignoreByUnnamedScopeOnMethod(): DataResponse { return new DataResponse(); } @@ -139,7 +124,7 @@ public function defaultAndAdminScope(): DataResponse { /** * @NoAdminRequired * - * Route is ignored because of scope on the controller + * Route is referencing nested schemas * * @return DataResponse, array{}> * @@ -152,7 +137,7 @@ public function nestedSchemas(): DataResponse { /** * @NoAdminRequired * - * Route is ignored because of scope on the controller + * Route is referencing a schema which is a list of schemas * * @return DataResponse * diff --git a/tests/openapi-administration.json b/tests/openapi-administration.json new file mode 100644 index 0000000..31d5a58 --- /dev/null +++ b/tests/openapi-administration.json @@ -0,0 +1,1835 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "notifications-administration", + "version": "0.0.1", + "description": "This app provides a backend and frontend for the notification API available in Nextcloud.", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": { + "OCSMeta": { + "type": "object", + "required": [ + "status", + "statuscode" + ], + "properties": { + "status": { + "type": "string" + }, + "statuscode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "totalitems": { + "type": "string" + }, + "itemsperpage": { + "type": "string" + } + } + }, + "PushDevice": { + "allOf": [ + { + "$ref": "#/components/schemas/PushDeviceBase" + }, + { + "type": "object", + "required": [ + "publicKey", + "signature" + ], + "properties": { + "publicKey": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + } + ] + }, + "PushDeviceBase": { + "type": "object", + "required": [ + "deviceIdentifier" + ], + "properties": { + "deviceIdentifier": { + "type": "string" + } + } + } + } + }, + "paths": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin": { + "post": { + "operationId": "admin_settings-admin-scope-implicit-from-admin-required", + "summary": "Route is only in the admin scope because there is no \"NoAdminRequired\" annotation or attribute", + "description": "This endpoint requires admin access", + "tags": [ + "admin_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/moved-with-tag": { + "post": { + "operationId": "settings-admin-settings-moved-to-settings-tag", + "summary": "Route in default scope with tags", + "description": "This endpoint requires admin access", + "tags": [ + "settings", + "admin-settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/moved-with-unnamed-tag": { + "post": { + "operationId": "settings-admin-settings-moved-to-settings-tag-unnamed", + "summary": "Route in default scope with tags but without named parameters on the attribute", + "description": "This endpoint requires admin access", + "tags": [ + "settings", + "admin-settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/admin-scope": { + "post": { + "operationId": "settings-moved-to-admin-scope", + "summary": "Route is only in the admin scope due to defined scope", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": { + "$ref": "#/components/schemas/PushDevice" + } + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-and-admin-scope": { + "post": { + "operationId": "settings-default-and-admin-scope", + "summary": "Route is in admin and default scope", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-of-int": { + "post": { + "operationId": "settings-list-of-int-parameters", + "summary": "A route with a limited set of possible integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "Maximum number of objects", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "enum": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/min-max": { + "post": { + "operationId": "settings-int-parameter-with-min-and-max", + "summary": "A route with a min and max integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "Between 5 and 10", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 5, + "maximum": 10 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/min": { + "post": { + "operationId": "settings-int-parameter-with-min", + "summary": "A route with a min integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "At least 5", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 5 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/max": { + "post": { + "operationId": "settings-int-parameter-with-max", + "summary": "A route with a max integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "At most 10", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "maximum": 10 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-one": { + "post": { + "operationId": "settings-list-of-int-string-and-one-bool", + "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "weird", + "in": "query", + "description": "Weird list", + "required": true, + "schema": { + "oneOf": [ + { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + { + "type": "string", + "enum": [ + "yes", + "no" + ] + }, + { + "type": "boolean", + "enum": [ + true + ] + } + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-all": { + "post": { + "operationId": "settings-list-of-int-string-and-all-bools", + "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "weird", + "in": "query", + "description": "Weird list", + "required": true, + "schema": { + "oneOf": [ + { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + { + "type": "string", + "enum": [ + "yes", + "no" + ] + }, + { + "type": "boolean", + "enum": [ + true, + false + ] + } + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean": { + "post": { + "operationId": "settings-boolean-parameter-required", + "summary": "A route with required boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean required", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-false": { + "post": { + "operationId": "settings-boolean-parameter-default-false", + "summary": "A route with boolean defaulting to false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean defaulting to false", + "schema": { + "type": "integer", + "default": 0, + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-true": { + "post": { + "operationId": "settings-boolean-parameter-default-true", + "summary": "A route with boolean defaulting to true", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean defaulting to true", + "schema": { + "type": "integer", + "default": 1, + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true": { + "post": { + "operationId": "settings-boolean-true-parameter", + "summary": "A route with boolean or true", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or true", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-false": { + "post": { + "operationId": "settings-boolean-false-parameter", + "summary": "A route with boolean or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true-false": { + "post": { + "operationId": "settings-boolean-true-false-parameter", + "summary": "A route with boolean or true or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or true or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/true-false": { + "post": { + "operationId": "settings-true-false-parameter", + "summary": "A route with true or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "true or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/string-value": { + "post": { + "operationId": "settings-string-value-parameter", + "summary": "A route with string or 'test'", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "value", + "in": "query", + "description": "string or 'test'", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/int-value": { + "post": { + "operationId": "settings-int-value-parameter", + "summary": "A route with int or 0", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "value", + "in": "query", + "description": "int or 0", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/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": [] +} \ No newline at end of file diff --git a/tests/openapi-federation.json b/tests/openapi-federation.json new file mode 100644 index 0000000..1df8ce0 --- /dev/null +++ b/tests/openapi-federation.json @@ -0,0 +1,123 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "notifications-federation", + "version": "0.0.1", + "description": "This app provides a backend and frontend for the notification API available in Nextcloud.", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": { + "OCSMeta": { + "type": "object", + "required": [ + "status", + "statuscode" + ], + "properties": { + "status": { + "type": "string" + }, + "statuscode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "totalitems": { + "type": "string" + }, + "itemsperpage": { + "type": "string" + } + } + } + } + }, + "paths": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/controller-scope": { + "post": { + "operationId": "federation-federation-by-controller", + "summary": "Route is in federation scope as per controller scope", + "tags": [ + "federation" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + } + }, + "tags": [] +} \ No newline at end of file diff --git a/tests/openapi-full.json b/tests/openapi-full.json new file mode 100644 index 0000000..5315901 --- /dev/null +++ b/tests/openapi-full.json @@ -0,0 +1,2325 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "notifications-full", + "version": "0.0.1", + "description": "This app provides a backend and frontend for the notification API available in Nextcloud.", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": { + "Collection": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Item" + } + }, + "Item": { + "type": "object", + "required": [ + "label", + "link", + "type", + "primary" + ], + "properties": { + "label": { + "type": "string" + }, + "link": { + "type": "string" + }, + "type": { + "type": "string" + }, + "primary": { + "type": "boolean" + } + } + }, + "Notification": { + "type": "object", + "required": [ + "notification_id", + "app", + "user", + "datetime", + "object_type", + "object_id", + "subject", + "message", + "link", + "actions" + ], + "properties": { + "notification_id": { + "type": "integer", + "format": "int64" + }, + "app": { + "type": "string" + }, + "user": { + "type": "string" + }, + "datetime": { + "type": "string" + }, + "object_type": { + "type": "string" + }, + "object_id": { + "type": "string" + }, + "subject": { + "type": "string" + }, + "message": { + "type": "string" + }, + "link": { + "type": "string" + }, + "actions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NotificationAction" + } + }, + "subjectRich": { + "type": "string" + }, + "subjectRichParameters": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "messageRich": { + "type": "string" + }, + "messageRichParameters": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "icon": { + "type": "string" + }, + "shouldNotify": { + "type": "boolean" + } + } + }, + "NotificationAction": { + "type": "object", + "required": [ + "label", + "link", + "type", + "primary" + ], + "properties": { + "label": { + "type": "string" + }, + "link": { + "type": "string" + }, + "type": { + "type": "string" + }, + "primary": { + "type": "boolean" + } + } + }, + "OCSMeta": { + "type": "object", + "required": [ + "status", + "statuscode" + ], + "properties": { + "status": { + "type": "string" + }, + "statuscode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "totalitems": { + "type": "string" + }, + "itemsperpage": { + "type": "string" + } + } + }, + "PushDevice": { + "allOf": [ + { + "$ref": "#/components/schemas/PushDeviceBase" + }, + { + "type": "object", + "required": [ + "publicKey", + "signature" + ], + "properties": { + "publicKey": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + } + ] + }, + "PushDeviceBase": { + "type": "object", + "required": [ + "deviceIdentifier" + ], + "properties": { + "deviceIdentifier": { + "type": "string" + } + } + } + } + }, + "paths": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin": { + "post": { + "operationId": "admin_settings-admin-scope-implicit-from-admin-required", + "summary": "Route is only in the admin scope because there is no \"NoAdminRequired\" annotation or attribute", + "description": "This endpoint requires admin access", + "tags": [ + "admin_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/moved-with-tag": { + "post": { + "operationId": "settings-admin-settings-moved-to-settings-tag", + "summary": "Route in default scope with tags", + "description": "This endpoint requires admin access", + "tags": [ + "settings", + "admin-settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/moved-with-unnamed-tag": { + "post": { + "operationId": "settings-admin-settings-moved-to-settings-tag-unnamed", + "summary": "Route in default scope with tags but without named parameters on the attribute", + "description": "This endpoint requires admin access", + "tags": [ + "settings", + "admin-settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/admin-scope": { + "post": { + "operationId": "settings-moved-to-admin-scope", + "summary": "Route is only in the admin scope due to defined scope", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": { + "$ref": "#/components/schemas/PushDevice" + } + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-and-admin-scope": { + "post": { + "operationId": "settings-default-and-admin-scope", + "summary": "Route is in admin and default scope", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-of-int": { + "post": { + "operationId": "settings-list-of-int-parameters", + "summary": "A route with a limited set of possible integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "Maximum number of objects", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "enum": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/min-max": { + "post": { + "operationId": "settings-int-parameter-with-min-and-max", + "summary": "A route with a min and max integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "Between 5 and 10", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 5, + "maximum": 10 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/min": { + "post": { + "operationId": "settings-int-parameter-with-min", + "summary": "A route with a min integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "At least 5", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 5 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/max": { + "post": { + "operationId": "settings-int-parameter-with-max", + "summary": "A route with a max integers", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "At most 10", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "maximum": 10 + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-one": { + "post": { + "operationId": "settings-list-of-int-string-and-one-bool", + "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "weird", + "in": "query", + "description": "Weird list", + "required": true, + "schema": { + "oneOf": [ + { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + { + "type": "string", + "enum": [ + "yes", + "no" + ] + }, + { + "type": "boolean", + "enum": [ + true + ] + } + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-all": { + "post": { + "operationId": "settings-list-of-int-string-and-all-bools", + "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "weird", + "in": "query", + "description": "Weird list", + "required": true, + "schema": { + "oneOf": [ + { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + { + "type": "string", + "enum": [ + "yes", + "no" + ] + }, + { + "type": "boolean", + "enum": [ + true, + false + ] + } + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean": { + "post": { + "operationId": "settings-boolean-parameter-required", + "summary": "A route with required boolean", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean required", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-false": { + "post": { + "operationId": "settings-boolean-parameter-default-false", + "summary": "A route with boolean defaulting to false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean defaulting to false", + "schema": { + "type": "integer", + "default": 0, + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-true": { + "post": { + "operationId": "settings-boolean-parameter-default-true", + "summary": "A route with boolean defaulting to true", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "Boolean defaulting to true", + "schema": { + "type": "integer", + "default": 1, + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true": { + "post": { + "operationId": "settings-boolean-true-parameter", + "summary": "A route with boolean or true", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or true", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-false": { + "post": { + "operationId": "settings-boolean-false-parameter", + "summary": "A route with boolean or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true-false": { + "post": { + "operationId": "settings-boolean-true-false-parameter", + "summary": "A route with boolean or true or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "boolean or true or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/true-false": { + "post": { + "operationId": "settings-true-false-parameter", + "summary": "A route with true or false", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "yesOrNo", + "in": "query", + "description": "true or false", + "required": true, + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/string-value": { + "post": { + "operationId": "settings-string-value-parameter", + "summary": "A route with string or 'test'", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "value", + "in": "query", + "description": "string or 'test'", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/int-value": { + "post": { + "operationId": "settings-int-value-parameter", + "summary": "A route with int or 0", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "value", + "in": "query", + "description": "int or 0", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "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": {} + } + } + } + } + } + } + } + } + } + }, + "/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": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin-overwritten": { + "post": { + "operationId": "admin_settings-moved-to-default-scope", + "summary": "Route is in the default scope because the method overwrites with the Attribute", + "description": "This endpoint requires admin access", + "tags": [ + "admin_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-scope": { + "post": { + "operationId": "federation-moved-to-default-scope", + "summary": "Route is only in the default scope (moved from federation)", + "tags": [ + "federation" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/nested-schemas": { + "post": { + "operationId": "settings-nested-schemas", + "summary": "Route is referencing nested schemas", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Notification" + } + } + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-schemas": { + "post": { + "operationId": "settings-list-schemas", + "summary": "Route is referencing a schema which is a list of schemas", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "$ref": "#/components/schemas/Collection" + } + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/notifications/api/{apiVersion}/controller-scope": { + "post": { + "operationId": "federation-federation-by-controller", + "summary": "Route is in federation scope as per controller scope", + "tags": [ + "federation" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + } + }, + "tags": [] +} \ No newline at end of file diff --git a/tests/openapi.json b/tests/openapi.json index 501197f..b67de7c 100644 --- a/tests/openapi.json +++ b/tests/openapi.json @@ -20,32 +20,27 @@ } }, "schemas": { - "Collection": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Item" - } - }, - "Item": { + "OCSMeta": { "type": "object", "required": [ - "label", - "link", - "type", - "primary" + "status", + "statuscode" ], "properties": { - "label": { + "status": { "type": "string" }, - "link": { + "statuscode": { + "type": "integer" + }, + "message": { "type": "string" }, - "type": { + "totalitems": { "type": "string" }, - "primary": { - "type": "boolean" + "itemsperpage": { + "type": "string" } } }, @@ -124,6 +119,12 @@ } } }, + "Collection": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Item" + } + }, "NotificationAction": { "type": "object", "required": [ @@ -147,138 +148,32 @@ } } }, - "OCSMeta": { + "Item": { "type": "object", "required": [ - "status", - "statuscode" + "label", + "link", + "type", + "primary" ], "properties": { - "status": { - "type": "string" - }, - "statuscode": { - "type": "integer" - }, - "message": { + "label": { "type": "string" }, - "totalitems": { + "link": { "type": "string" }, - "itemsperpage": { + "type": { "type": "string" - } - } - }, - "PushDevice": { - "allOf": [ - { - "$ref": "#/components/schemas/PushDeviceBase" }, - { - "type": "object", - "required": [ - "publicKey", - "signature" - ], - "properties": { - "publicKey": { - "type": "string" - }, - "signature": { - "type": "string" - } - } - } - ] - }, - "PushDeviceBase": { - "type": "object", - "required": [ - "deviceIdentifier" - ], - "properties": { - "deviceIdentifier": { - "type": "string" + "primary": { + "type": "boolean" } } } } }, "paths": { - "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin": { - "post": { - "operationId": "admin_settings-admin-scope-implicit-from-admin-required", - "summary": "Route is only in the admin scope because there is no \"NoAdminRequired\" annotation or attribute", - "description": "This endpoint requires admin access", - "tags": [ - "admin_settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "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": "Personal settings updated", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - } - } - } - }, "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin-overwritten": { "post": { "operationId": "admin_settings-moved-to-default-scope", @@ -351,13 +246,12 @@ } } }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/moved-with-tag": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-scope": { "post": { - "operationId": "admin_settings-moved-to-settings-tag", - "summary": "Route in default scope with tags", - "description": "This endpoint requires admin access", + "operationId": "federation-moved-to-default-scope", + "summary": "Route is only in the default scope (moved from federation)", "tags": [ - "admin_settings" + "federation" ], "security": [ { @@ -423,10 +317,10 @@ } } }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/controller-scope": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-and-admin-scope": { "post": { - "operationId": "settings-federation-by-controller", - "summary": "Route is ignored because of scope on the controller", + "operationId": "settings-default-and-admin-scope", + "summary": "Route is in admin and default scope", "tags": [ "settings" ], @@ -464,7 +358,7 @@ ], "responses": { "200": { - "description": "OK", + "description": "Admin settings updated", "content": { "application/json": { "schema": { @@ -494,10 +388,10 @@ } } }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/ignore-method-scope": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/nested-schemas": { "post": { - "operationId": "settings-ignore-by-scope-on-method", - "summary": "Route is ignored because of scope on the method", + "operationId": "settings-nested-schemas", + "summary": "Route is referencing nested schemas", "tags": [ "settings" ], @@ -554,78 +448,12 @@ "meta": { "$ref": "#/components/schemas/OCSMeta" }, - "data": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-scope": { - "post": { - "operationId": "settings-moved-to-default-scope", - "summary": "Route is only in the default scope", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "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": "Personal settings updated", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Notification" + } + } } } } @@ -636,10 +464,10 @@ } } }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/admin-scope": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-schemas": { "post": { - "operationId": "settings-moved-to-admin-scope", - "summary": "Route is only in the admin scope due to defined scope", + "operationId": "settings-list-schemas", + "summary": "Route is referencing a schema which is a list of schemas", "tags": [ "settings" ], @@ -677,7 +505,7 @@ ], "responses": { "200": { - "description": "Admin settings updated", + "description": "OK", "content": { "application/json": { "schema": { @@ -697,7 +525,7 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "$ref": "#/components/schemas/PushDevice" + "$ref": "#/components/schemas/Collection" } } } @@ -708,1614 +536,6 @@ } } } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-and-admin-scope": { - "post": { - "operationId": "settings-default-and-admin-scope", - "summary": "Route is in admin and default scope", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/nested-schemas": { - "post": { - "operationId": "settings-nested-schemas", - "summary": "Route is ignored because of scope on the controller", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "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": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Notification" - } - } - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-schemas": { - "post": { - "operationId": "settings-list-schemas", - "summary": "Route is ignored because of scope on the controller", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "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": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": { - "$ref": "#/components/schemas/Collection" - } - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/list-of-int": { - "post": { - "operationId": "settings-list-of-int-parameters", - "summary": "A route with a limited set of possible integers", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "Maximum number of objects", - "required": true, - "schema": { - "type": "integer", - "format": "int64", - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/min-max": { - "post": { - "operationId": "settings-int-parameter-with-min-and-max", - "summary": "A route with a min and max integers", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "Between 5 and 10", - "required": true, - "schema": { - "type": "integer", - "format": "int64", - "minimum": 5, - "maximum": 10 - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/min": { - "post": { - "operationId": "settings-int-parameter-with-min", - "summary": "A route with a min integers", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "At least 5", - "required": true, - "schema": { - "type": "integer", - "format": "int64", - "minimum": 5 - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/max": { - "post": { - "operationId": "settings-int-parameter-with-max", - "summary": "A route with a max integers", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "At most 10", - "required": true, - "schema": { - "type": "integer", - "format": "int64", - "maximum": 10 - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-one": { - "post": { - "operationId": "settings-list-of-int-string-and-one-bool", - "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "weird", - "in": "query", - "description": "Weird list", - "required": true, - "schema": { - "oneOf": [ - { - "type": "integer", - "enum": [ - 0, - 1 - ] - }, - { - "type": "string", - "enum": [ - "yes", - "no" - ] - }, - { - "type": "boolean", - "enum": [ - true - ] - } - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/mixed-list-all": { - "post": { - "operationId": "settings-list-of-int-string-and-all-bools", - "summary": "A route with a list of 2 integers, 2 strings and 1 boolean", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "weird", - "in": "query", - "description": "Weird list", - "required": true, - "schema": { - "oneOf": [ - { - "type": "integer", - "enum": [ - 0, - 1 - ] - }, - { - "type": "string", - "enum": [ - "yes", - "no" - ] - }, - { - "type": "boolean", - "enum": [ - true, - false - ] - } - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean": { - "post": { - "operationId": "settings-boolean-parameter-required", - "summary": "A route with required boolean", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "Boolean required", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-false": { - "post": { - "operationId": "settings-boolean-parameter-default-false", - "summary": "A route with boolean defaulting to false", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "Boolean defaulting to false", - "schema": { - "type": "integer", - "default": 0, - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-default-true": { - "post": { - "operationId": "settings-boolean-parameter-default-true", - "summary": "A route with boolean defaulting to true", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "Boolean defaulting to true", - "schema": { - "type": "integer", - "default": 1, - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true": { - "post": { - "operationId": "settings-boolean-true-parameter", - "summary": "A route with boolean or true", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "boolean or true", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-false": { - "post": { - "operationId": "settings-boolean-false-parameter", - "summary": "A route with boolean or false", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "boolean or false", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/boolean-true-false": { - "post": { - "operationId": "settings-boolean-true-false-parameter", - "summary": "A route with boolean or true or false", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "boolean or true or false", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/true-false": { - "post": { - "operationId": "settings-true-false-parameter", - "summary": "A route with true or false", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "yesOrNo", - "in": "query", - "description": "true or false", - "required": true, - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/string-value": { - "post": { - "operationId": "settings-string-value-parameter", - "summary": "A route with string or 'test'", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "value", - "in": "query", - "description": "string or 'test'", - "required": true, - "schema": { - "type": "string" - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/int-value": { - "post": { - "operationId": "settings-int-value-parameter", - "summary": "A route with int or 0", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "value", - "in": "query", - "description": "int or 0", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "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": {} - } - } - } - } - } - } - } - } - } - }, - "/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": []