unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
70 lines • 2.69 kB
JavaScript
import { mergeAllOfs } from '../util/all-of.js';
const tokenNameSchema = {
type: 'object',
required: ['tokenName'],
properties: {
tokenName: {
type: 'string',
description: 'The name of the token.',
example: 'token-64522',
},
},
};
const clientFrontendSchema = {
required: ['type'],
type: 'object',
properties: {
type: {
type: 'string',
pattern: '^([Cc][Ll][Ii][Ee][Nn][Tt]|[Ff][Rr][Oo][Nn][Tt][Ee][Nn][Dd])$',
description: `A client or frontend token. Must be one of the strings "client" or "frontend" (not case sensitive).`,
example: 'frontend',
},
environment: {
type: 'string',
description: 'The environment that the token should be valid for. Defaults to "default"',
example: 'development',
},
project: {
type: 'string',
description: 'The project that the token should be valid for. Defaults to "*" meaning every project. This property is mutually incompatible with the `projects` property. If you specify one, you cannot specify the other.',
example: 'project-851',
},
projects: {
type: 'array',
description: 'A list of projects that the token should be valid for. This property is mutually incompatible with the `project` property. If you specify one, you cannot specify the other.',
example: ['project-851', 'project-852'],
items: {
type: 'string',
},
},
},
};
const expireSchema = {
type: 'object',
properties: {
expiresAt: {
type: 'string',
format: 'date-time',
description: 'The time when this token should expire.',
example: '2023-07-04T11:26:24+02:00',
},
},
};
// TODO: (openapi) this schema isn't entirely correct: `project` and `projects`
// are mutually exclusive.
//
// That is, when creating a token, you can provide either `project` _or_
// `projects`, but *not* both.
//
// Because we allow additional properties, we cannot express the mutual
// exclusiveness in the schema (with OpenAPI 3.0). As such, it's mentioned in
// the description for now.
export const createApiTokenSchema = {
$id: '#/components/schemas/createApiTokenSchema',
type: 'object',
description: 'The data required to create an [Unleash API token](https://docs.getunleash.io/reference/api-tokens-and-client-keys).',
oneOf: [mergeAllOfs([expireSchema, clientFrontendSchema, tokenNameSchema])],
components: {},
};
//# sourceMappingURL=create-api-token-schema.js.map