mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-08 01:15:49 +02:00
feat: user openapi spec (#4162)
This commit is contained in:
parent
46b4030d47
commit
d7b7d93533
@ -104,21 +104,14 @@ const metaRules: Rule[] = [
|
|||||||
'featureTypeSchema',
|
'featureTypeSchema',
|
||||||
'featureTypesSchema',
|
'featureTypesSchema',
|
||||||
'featureVariantsSchema',
|
'featureVariantsSchema',
|
||||||
'feedbackSchema',
|
|
||||||
'groupSchema',
|
'groupSchema',
|
||||||
'groupsSchema',
|
'groupsSchema',
|
||||||
'groupUserModelSchema',
|
'groupUserModelSchema',
|
||||||
'maintenanceSchema',
|
'maintenanceSchema',
|
||||||
'toggleMaintenanceSchema',
|
'toggleMaintenanceSchema',
|
||||||
'meSchema',
|
|
||||||
'patchSchema',
|
'patchSchema',
|
||||||
'permissionSchema',
|
|
||||||
'profileSchema',
|
|
||||||
'projectSchema',
|
'projectSchema',
|
||||||
'projectsSchema',
|
'projectsSchema',
|
||||||
'proxyClientSchema',
|
|
||||||
'proxyFeatureSchema',
|
|
||||||
'proxyFeaturesSchema',
|
|
||||||
'pushVariantsSchema',
|
'pushVariantsSchema',
|
||||||
'resetPasswordSchema',
|
'resetPasswordSchema',
|
||||||
'requestsPerSecondSchema',
|
'requestsPerSecondSchema',
|
||||||
@ -171,23 +164,16 @@ const metaRules: Rule[] = [
|
|||||||
'featureTypeSchema',
|
'featureTypeSchema',
|
||||||
'featureTypesSchema',
|
'featureTypesSchema',
|
||||||
'featureVariantsSchema',
|
'featureVariantsSchema',
|
||||||
'feedbackSchema',
|
|
||||||
'groupSchema',
|
'groupSchema',
|
||||||
'groupsSchema',
|
'groupsSchema',
|
||||||
'groupUserModelSchema',
|
'groupUserModelSchema',
|
||||||
'maintenanceSchema',
|
'maintenanceSchema',
|
||||||
'toggleMaintenanceSchema',
|
'toggleMaintenanceSchema',
|
||||||
'meSchema',
|
|
||||||
'parametersSchema',
|
'parametersSchema',
|
||||||
'patchesSchema',
|
'patchesSchema',
|
||||||
'patchSchema',
|
'patchSchema',
|
||||||
'permissionSchema',
|
|
||||||
'playgroundSegmentSchema',
|
'playgroundSegmentSchema',
|
||||||
'playgroundStrategySchema',
|
'playgroundStrategySchema',
|
||||||
'profileSchema',
|
|
||||||
'proxyClientSchema',
|
|
||||||
'proxyFeatureSchema',
|
|
||||||
'proxyFeaturesSchema',
|
|
||||||
'pushVariantsSchema',
|
'pushVariantsSchema',
|
||||||
'resetPasswordSchema',
|
'resetPasswordSchema',
|
||||||
'requestsPerSecondSchema',
|
'requestsPerSecondSchema',
|
||||||
|
@ -4,20 +4,30 @@ export const feedbackSchema = {
|
|||||||
$id: '#/components/schemas/feedbackSchema',
|
$id: '#/components/schemas/feedbackSchema',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'User feedback information',
|
||||||
properties: {
|
properties: {
|
||||||
userId: {
|
userId: {
|
||||||
type: 'number',
|
description: 'Identifier of the current user giving feedback',
|
||||||
|
type: 'integer',
|
||||||
|
example: 2,
|
||||||
},
|
},
|
||||||
feedbackId: {
|
feedbackId: {
|
||||||
|
description: 'The name of the feedback session',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
example: 'pnps',
|
||||||
},
|
},
|
||||||
neverShow: {
|
neverShow: {
|
||||||
|
description:
|
||||||
|
'`true` when user opts-in to never show the feedback again.',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
example: false,
|
||||||
},
|
},
|
||||||
given: {
|
given: {
|
||||||
|
description: 'When this feedback was given',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
format: 'date-time',
|
format: 'date-time',
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
example: '2023-07-06T08:29:21.282Z',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -8,23 +8,27 @@ export const meSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ['user', 'permissions', 'feedback', 'splash'],
|
required: ['user', 'permissions', 'feedback', 'splash'],
|
||||||
|
description: 'Detailed user information',
|
||||||
properties: {
|
properties: {
|
||||||
user: {
|
user: {
|
||||||
$ref: '#/components/schemas/userSchema',
|
$ref: '#/components/schemas/userSchema',
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
|
description: 'User permissions for projects and environments',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
$ref: '#/components/schemas/permissionSchema',
|
$ref: '#/components/schemas/permissionSchema',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
feedback: {
|
feedback: {
|
||||||
|
description: 'User feedback information',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
$ref: '#/components/schemas/feedbackSchema',
|
$ref: '#/components/schemas/feedbackSchema',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
splash: {
|
splash: {
|
||||||
|
description: 'Splash screen configuration',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: {
|
additionalProperties: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -5,15 +5,23 @@ export const permissionSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ['permission'],
|
required: ['permission'],
|
||||||
|
description: 'Project and environment permissions',
|
||||||
properties: {
|
properties: {
|
||||||
permission: {
|
permission: {
|
||||||
|
description:
|
||||||
|
'[Project](https://docs.getunleash.io/reference/rbac#project-permissions) or [environment](https://docs.getunleash.io/reference/rbac#environment-permissions) permission name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
example: 'UPDATE_FEATURE_STRATEGY',
|
||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
|
description: 'The project this permission applies to',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
example: 'my-project',
|
||||||
},
|
},
|
||||||
environment: {
|
environment: {
|
||||||
|
description: 'The environment this permission applies to',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
example: 'development',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -6,22 +6,27 @@ export const profileSchema = {
|
|||||||
$id: '#/components/schemas/profileSchema',
|
$id: '#/components/schemas/profileSchema',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'User profile overview',
|
||||||
required: ['rootRole', 'projects', 'features'],
|
required: ['rootRole', 'projects', 'features'],
|
||||||
properties: {
|
properties: {
|
||||||
rootRole: {
|
rootRole: {
|
||||||
$ref: '#/components/schemas/roleSchema',
|
$ref: '#/components/schemas/roleSchema',
|
||||||
},
|
},
|
||||||
projects: {
|
projects: {
|
||||||
|
description: 'Which projects this user is a member of',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
example: ['my-projectA', 'my-projectB'],
|
||||||
},
|
},
|
||||||
features: {
|
features: {
|
||||||
|
description: 'Deprecated, always returns empty array',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
$ref: '#/components/schemas/featureSchema',
|
$ref: '#/components/schemas/featureSchema',
|
||||||
},
|
},
|
||||||
|
example: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -4,6 +4,7 @@ export const proxyClientSchema = {
|
|||||||
$id: '#/components/schemas/proxyClientSchema',
|
$id: '#/components/schemas/proxyClientSchema',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['appName', 'interval', 'started', 'strategies'],
|
required: ['appName', 'interval', 'started', 'strategies'],
|
||||||
|
description: 'Frontend SDK client registration information',
|
||||||
properties: {
|
properties: {
|
||||||
appName: {
|
appName: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -22,6 +23,8 @@ export const proxyClientSchema = {
|
|||||||
environment: {
|
environment: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
deprecated: true,
|
deprecated: true,
|
||||||
|
description: 'deprecated',
|
||||||
|
example: 'development',
|
||||||
},
|
},
|
||||||
interval: {
|
interval: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
@ -6,6 +6,7 @@ export const proxyFeatureSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['name', 'enabled', 'impressionData'],
|
required: ['name', 'enabled', 'impressionData'],
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'Frontend API feature',
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
name: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -27,6 +28,7 @@ export const proxyFeatureSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['name', 'enabled'],
|
required: ['name', 'enabled'],
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'Variant details',
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
name: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -6,8 +6,10 @@ export const proxyFeaturesSchema = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['toggles'],
|
required: ['toggles'],
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'Frontend SDK features list',
|
||||||
properties: {
|
properties: {
|
||||||
toggles: {
|
toggles: {
|
||||||
|
description: 'The actual features returned to the Frontend SDK',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
$ref: proxyFeatureSchema.$id,
|
$ref: proxyFeatureSchema.$id,
|
||||||
|
@ -15,7 +15,10 @@ import { meSchema, MeSchema } from '../../../openapi/spec/me-schema';
|
|||||||
import { serializeDates } from '../../../types/serialize-dates';
|
import { serializeDates } from '../../../types/serialize-dates';
|
||||||
import { IUserPermission } from '../../../types/stores/access-store';
|
import { IUserPermission } from '../../../types/stores/access-store';
|
||||||
import { PasswordSchema } from '../../../openapi/spec/password-schema';
|
import { PasswordSchema } from '../../../openapi/spec/password-schema';
|
||||||
import { emptyResponse } from '../../../openapi/util/standard-responses';
|
import {
|
||||||
|
emptyResponse,
|
||||||
|
getStandardResponses,
|
||||||
|
} from '../../../openapi/util/standard-responses';
|
||||||
import {
|
import {
|
||||||
profileSchema,
|
profileSchema,
|
||||||
ProfileSchema,
|
ProfileSchema,
|
||||||
@ -71,7 +74,13 @@ class UserController extends Controller {
|
|||||||
openApiService.validPath({
|
openApiService.validPath({
|
||||||
tags: ['Users'],
|
tags: ['Users'],
|
||||||
operationId: 'getMe',
|
operationId: 'getMe',
|
||||||
responses: { 200: createResponseSchema('meSchema') },
|
summary: 'Get your own user details',
|
||||||
|
description:
|
||||||
|
'Detailed information about the current user, user permissions and user feedback',
|
||||||
|
responses: {
|
||||||
|
200: createResponseSchema('meSchema'),
|
||||||
|
...getStandardResponses(401),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -85,7 +94,13 @@ class UserController extends Controller {
|
|||||||
openApiService.validPath({
|
openApiService.validPath({
|
||||||
tags: ['Users'],
|
tags: ['Users'],
|
||||||
operationId: 'getProfile',
|
operationId: 'getProfile',
|
||||||
responses: { 200: createResponseSchema('profileSchema') },
|
summary: 'Get your own user profile',
|
||||||
|
description:
|
||||||
|
'Detailed information about the current user root role and project membership',
|
||||||
|
responses: {
|
||||||
|
200: createResponseSchema('profileSchema'),
|
||||||
|
...getStandardResponses(401),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -99,11 +114,19 @@ class UserController extends Controller {
|
|||||||
openApiService.validPath({
|
openApiService.validPath({
|
||||||
tags: ['Users'],
|
tags: ['Users'],
|
||||||
operationId: 'changeMyPassword',
|
operationId: 'changeMyPassword',
|
||||||
|
summary: 'Change your own password',
|
||||||
|
description:
|
||||||
|
'Requires specifying old password and confirming new password',
|
||||||
requestBody: createRequestSchema('passwordSchema'),
|
requestBody: createRequestSchema('passwordSchema'),
|
||||||
responses: {
|
responses: {
|
||||||
200: emptyResponse,
|
200: emptyResponse,
|
||||||
400: { description: 'password mismatch' },
|
400: {
|
||||||
401: { description: 'incorrect old password' },
|
description: 'Old and new password do not match',
|
||||||
|
},
|
||||||
|
401: {
|
||||||
|
description:
|
||||||
|
'Old password is incorrect or user is not authenticated',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user