1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/src/lib/openapi/spec/public-signup-token-schema.ts
Thomas Heartman 1481c13b61
openapi: enable strict schema validation by default and fix (#4355)
Enable strict schema validation by default. It can still be overridden
by explicitly setting it to false.

I've also fixed the validation errors that appeared when turning it on.
I've opted for the simplest route and changed the schemas to comply with
the tests.
2023-07-31 11:04:13 +02:00

90 lines
2.9 KiB
TypeScript

import { FromSchema } from 'json-schema-to-ts';
import { userSchema } from './user-schema';
import { roleSchema } from './role-schema';
export const publicSignupTokenSchema = {
$id: '#/components/schemas/publicSignupTokenSchema',
description:
'Used for transporting a [public invite link](https://docs.getunleash.io/reference/public-signup#public-sign-up-tokens)',
type: 'object',
additionalProperties: false,
required: [
'secret',
'url',
'name',
'expiresAt',
'createdAt',
'createdBy',
'enabled',
'role',
],
properties: {
secret: {
description:
'The actual value of the token. This is the part that is used by Unleash to create an invite link',
type: 'string',
example: 'a3c84b25409ea8ca1782ef17f94a42fc',
},
url: {
description:
'The public signup link for the token. Users who follow this link will be taken to a signup page where they can create an Unleash user.',
type: 'string',
nullable: true,
example:
'https://sandbox.getunleash.io/enterprise/new-user?invite=a3c84b25409ea8ca1782ef17f94a42fc',
},
name: {
description: "The token's name. Only for displaying in the UI",
type: 'string',
example: 'Invite public viewers',
},
enabled: {
description:
'Whether the token is active. This property will always be `false` for a token that has expired.',
type: 'boolean',
example: true,
},
expiresAt: {
type: 'string',
description: 'The time when the token will expire.',
format: 'date-time',
example: '2023-04-12T11:13:31.960Z',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'When the token was created.',
example: '2023-04-12T11:13:31.960Z',
},
createdBy: {
description: "The creator's email or username",
example: 'someone@example.com',
type: 'string',
nullable: true,
},
users: {
type: 'array',
description: 'Array of users that have signed up using the token.',
items: {
$ref: '#/components/schemas/userSchema',
},
nullable: true,
},
role: {
description:
'Users who sign up using this token will be given this role.',
$ref: '#/components/schemas/roleSchema',
},
},
components: {
schemas: {
userSchema,
roleSchema,
},
},
} as const;
export type PublicSignupTokenSchema = FromSchema<
typeof publicSignupTokenSchema
>;