mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-19 00:15:43 +01:00
openapi: update the splash endpoints and schemas for splash (#4227)
This change updates the splash endpoints and related schemas for the admin ui tag.
This commit is contained in:
parent
eb1df78383
commit
a785465943
@ -108,7 +108,8 @@ import {
|
||||
setStrategySortOrderSchema,
|
||||
setUiConfigSchema,
|
||||
sortOrderSchema,
|
||||
splashSchema,
|
||||
splashRequestSchema,
|
||||
splashResponseSchema,
|
||||
stateSchema,
|
||||
strategiesSchema,
|
||||
strategySchema,
|
||||
@ -305,7 +306,8 @@ export const schemas: UnleashSchemas = {
|
||||
setStrategySortOrderSchema,
|
||||
setUiConfigSchema,
|
||||
sortOrderSchema,
|
||||
splashSchema,
|
||||
splashRequestSchema,
|
||||
splashResponseSchema,
|
||||
stateSchema,
|
||||
strategiesSchema,
|
||||
strategySchema,
|
||||
|
@ -111,7 +111,6 @@ const metaRules: Rule[] = [
|
||||
'resetPasswordSchema',
|
||||
'sdkContextSchema',
|
||||
'setUiConfigSchema',
|
||||
'splashSchema',
|
||||
'stateSchema',
|
||||
'strategiesSchema',
|
||||
'uiConfigSchema',
|
||||
@ -160,7 +159,6 @@ const metaRules: Rule[] = [
|
||||
'setStrategySortOrderSchema',
|
||||
'setUiConfigSchema',
|
||||
'sortOrderSchema',
|
||||
'splashSchema',
|
||||
'strategiesSchema',
|
||||
'uiConfigSchema',
|
||||
'updateFeatureSchema',
|
||||
|
@ -21,7 +21,8 @@ export * from './users-schema';
|
||||
export * from './addons-schema';
|
||||
export * from './events-schema';
|
||||
export * from './groups-schema';
|
||||
export * from './splash-schema';
|
||||
export * from './splash-request-schema';
|
||||
export * from './splash-response-schema';
|
||||
export * from './feature-schema';
|
||||
export * from './patches-schema';
|
||||
export * from './profile-schema';
|
||||
|
23
src/lib/openapi/spec/splash-request-schema.ts
Normal file
23
src/lib/openapi/spec/splash-request-schema.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { FromSchema } from 'json-schema-to-ts';
|
||||
|
||||
export const splashRequestSchema = {
|
||||
$id: '#/components/schemas/splashRequestSchema',
|
||||
type: 'object',
|
||||
description: 'Data related to a user having seen a splash screen.',
|
||||
required: ['userId', 'splashId'],
|
||||
properties: {
|
||||
userId: {
|
||||
type: 'integer',
|
||||
description: 'The ID of the user that was shown the splash screen.',
|
||||
example: 1,
|
||||
},
|
||||
splashId: {
|
||||
type: 'string',
|
||||
description: 'The ID of the splash screen that was shown.',
|
||||
example: 'new-splash-screen',
|
||||
},
|
||||
},
|
||||
components: {},
|
||||
} as const;
|
||||
|
||||
export type SplashRequestSchema = FromSchema<typeof splashRequestSchema>;
|
22
src/lib/openapi/spec/splash-response-schema.ts
Normal file
22
src/lib/openapi/spec/splash-response-schema.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { FromSchema } from 'json-schema-to-ts';
|
||||
import { splashRequestSchema } from './splash-request-schema';
|
||||
|
||||
export const splashResponseSchema = {
|
||||
...splashRequestSchema,
|
||||
$id: '#/components/schemas/splashResponseSchema',
|
||||
additionalProperties: false,
|
||||
description: 'Data related to a user having seen a splash screen.',
|
||||
required: [...splashRequestSchema.required, 'seen'],
|
||||
properties: {
|
||||
...splashRequestSchema.properties,
|
||||
seen: {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Indicates whether the user has seen the splash screen or not.',
|
||||
example: true,
|
||||
},
|
||||
},
|
||||
components: {},
|
||||
} as const;
|
||||
|
||||
export type SplashResponseSchema = FromSchema<typeof splashResponseSchema>;
|
@ -1,22 +0,0 @@
|
||||
import { FromSchema } from 'json-schema-to-ts';
|
||||
|
||||
export const splashSchema = {
|
||||
$id: '#/components/schemas/splashSchema',
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['userId', 'splashId', 'seen'],
|
||||
properties: {
|
||||
userId: {
|
||||
type: 'number',
|
||||
},
|
||||
splashId: {
|
||||
type: 'string',
|
||||
},
|
||||
seen: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
components: {},
|
||||
} as const;
|
||||
|
||||
export type SplashSchema = FromSchema<typeof splashSchema>;
|
@ -8,7 +8,9 @@ import { IAuthRequest } from '../unleash-types';
|
||||
import { NONE } from '../../types/permissions';
|
||||
import { OpenApiService } from '../../services/openapi-service';
|
||||
import { createResponseSchema } from '../../openapi/util/create-response-schema';
|
||||
import { splashSchema, SplashSchema } from '../../openapi/spec/splash-schema';
|
||||
import { splashRequestSchema } from '../../openapi/spec/splash-request-schema';
|
||||
import { getStandardResponses } from '../../openapi';
|
||||
import { SplashResponseSchema } from 'lib/openapi/spec/splash-response-schema';
|
||||
|
||||
class UserSplashController extends Controller {
|
||||
private logger: Logger;
|
||||
@ -39,7 +41,13 @@ class UserSplashController extends Controller {
|
||||
openApiService.validPath({
|
||||
tags: ['Admin UI'],
|
||||
operationId: 'updateSplashSettings',
|
||||
responses: { 200: createResponseSchema('splashSchema') },
|
||||
summary: 'Update splash settings',
|
||||
description:
|
||||
'This operation updates splash settings for a user, indicating that they have seen a particualar splash screen.',
|
||||
responses: {
|
||||
200: createResponseSchema('splashResponseSchema'),
|
||||
...getStandardResponses(400, 401, 403, 415),
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
@ -47,7 +55,7 @@ class UserSplashController extends Controller {
|
||||
|
||||
private async updateSplashSettings(
|
||||
req: IAuthRequest<{ id: string }>,
|
||||
res: Response<SplashSchema>,
|
||||
res: Response<SplashResponseSchema>,
|
||||
): Promise<void> {
|
||||
const { user } = req;
|
||||
const { id } = req.params;
|
||||
@ -61,7 +69,7 @@ class UserSplashController extends Controller {
|
||||
this.openApiService.respondWithValidation(
|
||||
200,
|
||||
res,
|
||||
splashSchema.$id,
|
||||
splashRequestSchema.$id,
|
||||
await this.userSplashService.updateSplash(splash),
|
||||
);
|
||||
}
|
||||
|
@ -33,7 +33,13 @@ beforeAll(async () => {
|
||||
);
|
||||
};
|
||||
|
||||
app = await setupAppWithCustomAuth(stores, preHook);
|
||||
app = await setupAppWithCustomAuth(stores, preHook, {
|
||||
experimental: {
|
||||
flags: {
|
||||
strictSchemaValidation: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user