mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
feat: schema for paginated applications (#6309)
This commit is contained in:
parent
ff70a92956
commit
81ab77cf7c
57
src/lib/openapi/spec/applications-query-parameters.ts
Normal file
57
src/lib/openapi/spec/applications-query-parameters.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { FromQueryParams } from '../util/from-query-params';
|
||||
|
||||
export const applicationsQueryParameters = [
|
||||
{
|
||||
name: 'query',
|
||||
schema: {
|
||||
type: 'string',
|
||||
example: 'first_app',
|
||||
},
|
||||
description: 'The search query for the application name',
|
||||
in: 'query',
|
||||
},
|
||||
{
|
||||
name: 'offset',
|
||||
schema: {
|
||||
type: 'string',
|
||||
example: '50',
|
||||
},
|
||||
description:
|
||||
'The number of applications to skip when returning a page. By default it is set to 0.',
|
||||
in: 'query',
|
||||
},
|
||||
{
|
||||
name: 'limit',
|
||||
schema: {
|
||||
type: 'string',
|
||||
example: '50',
|
||||
},
|
||||
description:
|
||||
'The number of applications to return in a page. By default it is set to 1000.',
|
||||
in: 'query',
|
||||
},
|
||||
{
|
||||
name: 'sortBy',
|
||||
schema: {
|
||||
type: 'string',
|
||||
example: 'type',
|
||||
},
|
||||
description:
|
||||
'The field to sort the results by. By default it is set to "appName".',
|
||||
in: 'query',
|
||||
},
|
||||
{
|
||||
name: 'sortOrder',
|
||||
schema: {
|
||||
type: 'string',
|
||||
example: 'desc',
|
||||
},
|
||||
description:
|
||||
'The sort order for the sortBy. By default it is det to "asc".',
|
||||
in: 'query',
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type ApplicationsQueryParameters = Partial<
|
||||
FromQueryParams<typeof applicationsQueryParameters>
|
||||
>;
|
@ -7,8 +7,14 @@ export const applicationsSchema = {
|
||||
additionalProperties: false,
|
||||
description:
|
||||
'An object containing a list of applications that have connected to Unleash via an SDK.',
|
||||
required: ['total', 'applications'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
total: {
|
||||
type: 'integer',
|
||||
example: 50,
|
||||
description: 'The total number of project applications.',
|
||||
},
|
||||
applications: {
|
||||
description:
|
||||
'The list of applications that have connected to this Unleash instance.',
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
applicationOverviewSchema,
|
||||
} from '../../openapi/spec/application-overview-schema';
|
||||
import { OpenApiService } from '../../services';
|
||||
import { applicationsQueryParameters } from '../../openapi/spec/applications-query-parameters';
|
||||
|
||||
class MetricsController extends Controller {
|
||||
private logger: Logger;
|
||||
@ -104,6 +105,7 @@ class MetricsController extends Controller {
|
||||
summary: 'Get all applications',
|
||||
description:
|
||||
'Returns all applications registered with Unleash. Applications can be created via metrics reporting or manual creation',
|
||||
parameters: [...applicationsQueryParameters],
|
||||
operationId: 'getApplications',
|
||||
responses: {
|
||||
200: createResponseSchema('applicationsSchema'),
|
||||
@ -193,7 +195,8 @@ class MetricsController extends Controller {
|
||||
query,
|
||||
extractUserIdFromUser(user),
|
||||
);
|
||||
res.json({ applications });
|
||||
// todo: change to total with pagination later
|
||||
res.json({ applications, total: applications.length });
|
||||
}
|
||||
|
||||
async getApplication(
|
||||
|
Loading…
Reference in New Issue
Block a user