diff --git a/packages/core/src/routes/swagger/index.ts b/packages/core/src/routes/swagger/index.ts index 1771c06d8..6248f9e08 100644 --- a/packages/core/src/routes/swagger/index.ts +++ b/packages/core/src/routes/swagger/index.ts @@ -37,6 +37,7 @@ import { buildOperationId, customRoutes, throwByDifference } from './utils/opera import { buildParameters, paginationParameters, + searchParameters, buildPathIdParameters, mergeParameters, customParameters, @@ -50,12 +51,25 @@ const anonymousPaths = new Set([ 'status', ]); +const advancedSearchPaths = new Set([ + '/applications', + '/applications/:applicationId/roles', + '/resources/:resourceId/scopes', + '/roles/:id/applications', + '/roles/:id/scopes', + '/roles', + '/roles/:id/users', + '/users', + '/users/:userId/roles', +]); + type RouteObject = { path: string; method: OpenAPIV3.HttpMethods; operation: OpenAPIV3.OperationObject; }; +// eslint-disable-next-line complexity const buildOperation = ( method: OpenAPIV3.HttpMethods, stack: IMiddleware[], @@ -72,6 +86,7 @@ const buildOperation = ( const queryParameters = [ ...buildParameters(query, 'query'), ...(hasPagination ? paginationParameters : []), + ...(advancedSearchPaths.has(path) && method === 'get' ? [searchParameters] : []), ]; const requestBody = body && { diff --git a/packages/core/src/routes/swagger/utils/parameters.ts b/packages/core/src/routes/swagger/utils/parameters.ts index c7486c2ee..54356a409 100644 --- a/packages/core/src/routes/swagger/utils/parameters.ts +++ b/packages/core/src/routes/swagger/utils/parameters.ts @@ -41,6 +41,20 @@ export const paginationParameters: OpenAPIV3.ParameterObject[] = [ }, ]; +export const searchParameters: OpenAPIV3.ParameterObject = { + name: 'search_params', + in: 'query', + description: 'Search query parameters.', + required: false, + schema: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + explode: true, +}; + type BuildParameters = { /** * Build a parameter array for the given `ZodObject`.