diff --git a/src/openapi/authSchemas.ts b/src/openapi/authSchemas.ts new file mode 100644 index 0000000..4e840bf --- /dev/null +++ b/src/openapi/authSchemas.ts @@ -0,0 +1,240 @@ +import type { JSONSchema4 } from 'json-schema' +import type { OpenAPIV3_1 } from 'openapi-types' + +export const forgotPasswordRequestBodySchema: OpenAPIV3_1.SchemaObject = { + title: 'Forgot password request', + properties: { + email: { + type: 'string', + }, + }, + required: ['email'], +} + +export const forgotPasswordResponseSchema: JSONSchema4 = { + title: 'Forgot password response', + properties: { + message: { + type: 'string', + }, + }, + required: ['message'], +} + +export const loginRequestBodySchema: OpenAPIV3_1.SchemaObject = { + title: 'Login request', + properties: { + email: { + type: 'string', + }, + password: { + type: 'string', + }, + }, + required: ['email', 'password'], +} + +export const loginResponseSchema: JSONSchema4 = { + title: 'Login response', + properties: { + message: { + type: 'string', + }, + user: { + type: 'object', + additionalProperties: false, + properties: { + id: { + type: 'string', + }, + email: { + type: 'string', + }, + _verified: { + type: 'boolean', + }, + createdAt: { + type: 'string', + format: 'date-time', + }, + updatedAt: { + type: 'string', + format: 'date-time', + }, + }, + required: ['id', 'email', '_verified', 'createdAt', 'updatedAt'], + }, + token: { + type: 'string', + }, + exp: { + type: 'number', + }, + }, + required: ['message', 'user', 'token', 'exp'], +} + +export const logoutResponseSchema: JSONSchema4 = { + title: 'Logout response', + properties: { + message: { + type: 'string', + }, + }, + required: ['message'], +} + +export const meResponseSchema: JSONSchema4 = { + title: 'Me response', + properties: { + user: { + type: 'object', + additionalProperties: false, + properties: { + id: { + type: 'string', + }, + email: { + type: 'string', + }, + _verified: { + type: 'boolean', + }, + createdAt: { + type: 'string', + format: 'date-time', + }, + updatedAt: { + type: 'string', + format: 'date-time', + }, + _strategy: { + type: 'string', + }, + }, + required: ['id', 'email', '_verified', 'createdAt', 'updatedAt', '_strategy'], + }, + collection: { + type: 'string', + }, + token: { + type: 'string', + }, + exp: { + type: 'number', + }, + }, + required: ['user', 'collection', 'token', 'exp'], +} + +export const refreshTokenResponseSchema: JSONSchema4 = { + title: 'Refresh token response', + properties: { + message: { + type: 'string', + }, + user: { + type: 'object', + additionalProperties: false, + properties: { + id: { + type: 'string', + }, + email: { + type: 'string', + }, + collection: { + type: 'string', + }, + }, + required: ['id', 'email', 'collection'], + }, + refreshedToken: { + type: 'string', + }, + exp: { + type: 'number', + }, + }, + required: ['message', 'user', 'refreshedToken', 'exp'], +} + +export const resetPasswordRequestBodySchema: OpenAPIV3_1.SchemaObject = { + title: 'Reset password request', + properties: { + token: { + type: 'string', + }, + password: { + type: 'string', + }, + }, + required: ['token', 'password'], +} + +export const resetPasswordResponseSchema: JSONSchema4 = { + title: 'Reset password response', + properties: { + message: { + type: 'string', + }, + token: { + type: 'string', + }, + user: { + type: 'object', + additionalProperties: false, + properties: { + id: { + type: 'string', + }, + email: { + type: 'string', + }, + _verified: { + type: 'boolean', + }, + createdAt: { + type: 'string', + format: 'date-time', + }, + updatedAt: { + type: 'string', + format: 'date-time', + }, + }, + required: ['id', 'email', '_verified', 'createdAt', 'updatedAt'], + }, + }, + required: ['message', 'token', 'user'], +} + +export const unlockRequestBodySchema: OpenAPIV3_1.SchemaObject = { + title: 'Unlock request', + properties: { + email: { + type: 'string', + }, + }, + required: ['email'], +} + +export const unlockResponseSchema: JSONSchema4 = { + title: 'Unlock response', + properties: { + message: { + type: 'string', + }, + }, + required: ['message'], +} + +export const verifyUserResponseSchema: JSONSchema4 = { + title: 'Verify user response', + properties: { + message: { + type: 'string', + }, + }, + required: ['message'], +} diff --git a/src/openapi/generators.ts b/src/openapi/generators.ts index 961c692..d65e670 100644 --- a/src/openapi/generators.ts +++ b/src/openapi/generators.ts @@ -18,6 +18,20 @@ import type { import { entityToJSONSchema } from 'payload' import type { SanitizedPluginOptions } from '../types.js' import { mapValuesAsync, visitObjectNodes } from '../utils/objects.js' +import { + forgotPasswordRequestBodySchema, + forgotPasswordResponseSchema, + loginRequestBodySchema, + loginResponseSchema, + logoutResponseSchema, + meResponseSchema, + refreshTokenResponseSchema, + resetPasswordRequestBodySchema, + resetPasswordResponseSchema, + unlockRequestBodySchema, + unlockResponseSchema, + verifyUserResponseSchema, +} from './authSchemas.js' import { type ComponentType, collectionName, componentName, globalName } from './naming.js' import { apiKeySecurity, generateSecuritySchemes } from './securitySchemes.js' @@ -102,6 +116,24 @@ const generateSchemaObject = (config: SanitizedConfig, collection: Collection): } } +const generateAuthSchemaObjects = (collectionName: string) => { + const schemas: Record = { + [componentName('schemas', collectionName, { suffix: 'ForgotPassword' })]: + forgotPasswordResponseSchema, + [componentName('schemas', collectionName, { suffix: 'Login' })]: loginResponseSchema, + [componentName('schemas', collectionName, { suffix: 'Logout' })]: logoutResponseSchema, + [componentName('schemas', collectionName, { suffix: 'Me' })]: meResponseSchema, + [componentName('schemas', collectionName, { suffix: 'RefreshToken' })]: + refreshTokenResponseSchema, + [componentName('schemas', collectionName, { suffix: 'ResetPassword' })]: + resetPasswordResponseSchema, + [componentName('schemas', collectionName, { suffix: 'Unlock' })]: unlockResponseSchema, + [componentName('schemas', collectionName, { suffix: 'Verify' })]: verifyUserResponseSchema, + } + + return schemas +} + type RequestBodyType = 'post' | 'patch' const requestBodySchema = (fields: Array, schema: JSONSchema4): JSONSchema4 => ({ @@ -155,6 +187,49 @@ const generateRequestBodySchema = ( } } +const getRequestBodySchema = ( + description: string, + schema: OpenAPIV3_1.SchemaObject, +): OpenAPIV3_1.RequestBodyObject => { + return { + description, + content: { + 'application/json': { + schema: { + type: 'object', + additionalProperties: false, + ...schema, + }, + }, + }, + } +} + +const generateRequestBodyAuthSchemas = (collectionName: string) => { + const requestBodies: Record = { + [componentName('requestBodies', collectionName, { suffix: 'ForgotPassword' })]: + getRequestBodySchema( + `Forgot password request for ${collectionName}`, + forgotPasswordRequestBodySchema, + ), + [componentName('requestBodies', collectionName, { suffix: 'Login' })]: getRequestBodySchema( + `Login request for ${collectionName}`, + loginRequestBodySchema, + ), + [componentName('requestBodies', collectionName, { suffix: 'ResetPassword' })]: + getRequestBodySchema( + `Reset password request for ${collectionName}`, + resetPasswordRequestBodySchema, + ), + [componentName('requestBodies', collectionName, { suffix: 'Unlock' })]: getRequestBodySchema( + `Unlock request for ${collectionName}`, + unlockRequestBodySchema, + ), + } + + return requestBodies +} + const generateQueryOperationSchemas = (collection: Collection): Record => { const { singular } = collectionName(collection) @@ -353,6 +428,84 @@ const generateCollectionResponses = ( }, }, }, + ...generateCollectionAuthResponses(collection), + } +} + +const generateCollectionAuthResponses = ( + collection: Collection, +): Record => { + if (!collection.config.auth) { + return {} + } + + const { singular } = collectionName(collection) + + return { + [componentName('responses', singular, { suffix: 'ForgotPassword' })]: { + description: `${singular} forgot password object`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'ForgotPassword' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'Login' })]: { + description: `${singular} auth object`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'Login' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'Logout' })]: { + description: `${singular} logout response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'Logout' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'Me' })]: { + description: `${singular} me response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'Me' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'RefreshToken' })]: { + description: `${singular} refresh token response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'RefreshToken' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'ResetPassword' })]: { + description: `${singular} reset password response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'ResetPassword' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'Unlock' })]: { + description: `${singular} unlock response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'Unlock' }), + }, + }, + }, + [componentName('responses', singular, { suffix: 'Verify' })]: { + description: `${singular} verify response`, + content: { + 'application/json': { + schema: composeRef('schemas', singular, { suffix: 'Verify' }), + }, + }, + }, } } @@ -488,6 +641,109 @@ const generateCollectionOperations = async ( security: (await isOpenToPublic(collection.config.access.delete)) ? [] : [apiKeySecurity], }, }, + ...(await generateCollectionAuthOperations(collection)), + } +} + +const generateCollectionAuthOperations = async ( + collection: Collection, +): Promise> => { + if (!collection.config.auth) { + return {} + } + + const { slug } = collection.config + const { singular, plural } = collectionName(collection) + const tags = [plural] + + return { + [`/api/${slug}/forgot-password`]: { + post: { + summary: `Forgot password for ${singular}`, + tags, + requestBody: composeRef('requestBodies', singular, { suffix: 'ForgotPassword' }), + responses: { + 200: composeRef('responses', singular, { suffix: 'ForgotPassword' }), + }, + }, + }, + [`/api/${slug}/login`]: { + post: { + summary: `Log in to ${singular}`, + tags, + requestBody: composeRef('requestBodies', singular, { suffix: 'Login' }), + responses: { + 200: composeRef('responses', singular, { suffix: 'Login' }), + }, + }, + }, + [`/api/${slug}/logout`]: { + post: { + summary: `Log out of ${singular}`, + tags, + responses: { + 200: composeRef('responses', singular, { suffix: 'Logout' }), + }, + }, + }, + [`/api/${slug}/me`]: { + post: { + summary: `Get current ${singular}`, + tags, + responses: { + 200: composeRef('responses', singular, { suffix: 'Me' }), + }, + }, + }, + [`/api/${slug}/refresh-token`]: { + post: { + summary: `Refresh token for ${singular}`, + tags, + responses: { + 200: composeRef('responses', singular, { suffix: 'RefreshToken' }), + }, + }, + }, + [`/api/${slug}/reset-password`]: { + post: { + summary: `Reset password for ${singular}`, + tags, + requestBody: composeRef('requestBodies', singular, { suffix: 'ResetPassword' }), + responses: { + 200: composeRef('responses', singular, { suffix: 'ResetPassword' }), + }, + }, + }, + [`/api/${slug}/unlock`]: { + post: { + summary: `Unlock ${singular}`, + tags, + requestBody: composeRef('requestBodies', singular, { suffix: 'Unlock' }), + responses: { + 200: composeRef('responses', singular, { suffix: 'Unlock' }), + }, + }, + }, + [`/api/${slug}/verify/{token}`]: { + parameters: [ + { + in: 'path', + name: 'token', + description: `Verification token for ${singular}`, + required: true, + schema: { + type: 'string', + }, + }, + ], + post: { + summary: `Verify ${singular}`, + tags, + responses: { + 200: composeRef('responses', singular, { suffix: 'Verify' }), + }, + }, + }, } } @@ -587,6 +843,10 @@ const generateComponents = (req: Pick) => { req.payload.config, collection, ) + + if (collection.config.auth) { + Object.assign(schemas, generateAuthSchemaObjects(singular)) + } } for (const collection of Object.values(req.payload.collections)) { @@ -608,6 +868,10 @@ const generateComponents = (req: Pick) => { ) requestBodies[componentName('requestBodies', singular, { suffix: 'Patch' })] = generateRequestBodySchema(req.payload.config, collection, 'patch') + + if (collection.config.auth) { + Object.assign(requestBodies, generateRequestBodyAuthSchemas(singular)) + } } for (const global of req.payload.globals.config) { diff --git a/test/__snapshots__/openapi-generators.test.ts.snap b/test/__snapshots__/openapi-generators.test.ts.snap index 09d833e..fef269d 100644 --- a/test/__snapshots__/openapi-generators.test.ts.snap +++ b/test/__snapshots__/openapi-generators.test.ts.snap @@ -196,6 +196,50 @@ exports[`openapi generators > converts empty config correctly 1`] = ` }, "description": "Payload Preference", }, + "UsersForgotPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Forgot password request", + "type": "object", + }, + }, + }, + "description": "Forgot password request for users", + }, + "UsersLoginRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "type": "string", + }, + }, + "required": [ + "email", + "password", + ], + "title": "Login request", + "type": "object", + }, + }, + }, + "description": "Login request for users", + }, "UsersPatchRequestBody": { "content": { "application/json": { @@ -338,6 +382,50 @@ exports[`openapi generators > converts empty config correctly 1`] = ` }, "description": "users", }, + "UsersResetPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "password": { + "type": "string", + }, + "token": { + "type": "string", + }, + }, + "required": [ + "token", + "password", + ], + "title": "Reset password request", + "type": "object", + }, + }, + }, + "description": "Reset password request for users", + }, + "UsersUnlockRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Unlock request", + "type": "object", + }, + }, + }, + "description": "Unlock request for users", + }, }, "responses": { "NewPayloadLockedDocumentResponse": { @@ -747,6 +835,16 @@ exports[`openapi generators > converts empty config correctly 1`] = ` }, "description": "Payload Preference object", }, + "UsersForgotPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersForgotPassword", + }, + }, + }, + "description": "users forgot password object", + }, "UsersListResponse": { "content": { "application/json": { @@ -806,10 +904,60 @@ exports[`openapi generators > converts empty config correctly 1`] = ` }, "description": "List of users", }, + "UsersLoginResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogin", + }, + }, + }, + "description": "users auth object", + }, + "UsersLogoutResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogout", + }, + }, + }, + "description": "users logout response", + }, + "UsersMeResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersMe", + }, + }, + }, + "description": "users me response", + }, "UsersNotFoundResponse": { "content": {}, "description": "users not found", }, + "UsersRefreshTokenResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersRefreshToken", + }, + }, + }, + "description": "users refresh token response", + }, + "UsersResetPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersResetPassword", + }, + }, + }, + "description": "users reset password response", + }, "UsersResponse": { "content": { "application/json": { @@ -820,6 +968,26 @@ exports[`openapi generators > converts empty config correctly 1`] = ` }, "description": "users object", }, + "UsersUnlockResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersUnlock", + }, + }, + }, + "description": "users unlock response", + }, + "UsersVerifyResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersVerify", + }, + }, + }, + "description": "users verify response", + }, }, "schemas": { "PayloadLockedDocument": { @@ -1565,6 +1733,132 @@ exports[`openapi generators > converts empty config correctly 1`] = ` "title": "users", "type": "object", }, + "UsersForgotPassword": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Forgot password response", + }, + "UsersLogin": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "token", + "exp", + ], + "title": "Login response", + }, + "UsersLogout": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Logout response", + }, + "UsersMe": { + "properties": { + "collection": { + "type": "string", + }, + "exp": { + "type": "number", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_strategy": { + "type": "string", + }, + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + "_strategy", + ], + "type": "object", + }, + }, + "required": [ + "user", + "collection", + "token", + "exp", + ], + "title": "Me response", + }, "UsersQueryOperations": { "properties": { "createdAt": { @@ -1882,6 +2176,114 @@ exports[`openapi generators > converts empty config correctly 1`] = ` "title": "users query disjunction", "type": "object", }, + "UsersRefreshToken": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "refreshedToken": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "collection": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "email", + "collection", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "refreshedToken", + "exp", + ], + "title": "Refresh token response", + }, + "UsersResetPassword": { + "properties": { + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "token", + "user", + ], + "title": "Reset password response", + }, + "UsersUnlock": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Unlock response", + }, + "UsersVerify": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Verify user response", + }, "supportedTimezones": { "example": "Europe/Prague", "type": "string", @@ -2738,6 +3140,133 @@ exports[`openapi generators > converts empty config correctly 1`] = ` ], }, }, + "/api/users/forgot-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersForgotPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersForgotPasswordResponse", + }, + }, + "summary": "Forgot password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/login": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersLoginRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersLoginResponse", + }, + }, + "summary": "Log in to users", + "tags": [ + "users", + ], + }, + }, + "/api/users/logout": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersLogoutResponse", + }, + }, + "summary": "Log out of users", + "tags": [ + "users", + ], + }, + }, + "/api/users/me": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersMeResponse", + }, + }, + "summary": "Get current users", + "tags": [ + "users", + ], + }, + }, + "/api/users/refresh-token": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersRefreshTokenResponse", + }, + }, + "summary": "Refresh token for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/reset-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersResetPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersResetPasswordResponse", + }, + }, + "summary": "Reset password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/unlock": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersUnlockRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersUnlockResponse", + }, + }, + "summary": "Unlock users", + "tags": [ + "users", + ], + }, + }, + "/api/users/verify/{token}": { + "parameters": [ + { + "description": "Verification token for users", + "in": "path", + "name": "token", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersVerifyResponse", + }, + }, + "summary": "Verify users", + "tags": [ + "users", + ], + }, + }, "/api/users/{id}": { "delete": { "operationId": "deleteUsers", @@ -3278,6 +3807,50 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` }, "description": "Payload Preference", }, + "UsersForgotPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Forgot password request", + "type": "object", + }, + }, + }, + "description": "Forgot password request for users", + }, + "UsersLoginRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "type": "string", + }, + }, + "required": [ + "email", + "password", + ], + "title": "Login request", + "type": "object", + }, + }, + }, + "description": "Login request for users", + }, "UsersPatchRequestBody": { "content": { "application/json": { @@ -3420,6 +3993,50 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` }, "description": "users", }, + "UsersResetPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "password": { + "type": "string", + }, + "token": { + "type": "string", + }, + }, + "required": [ + "token", + "password", + ], + "title": "Reset password request", + "type": "object", + }, + }, + }, + "description": "Reset password request for users", + }, + "UsersUnlockRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Unlock request", + "type": "object", + }, + }, + }, + "description": "Unlock request for users", + }, }, "responses": { "NewPageResponse": { @@ -3949,6 +4566,16 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` }, "description": "Payload Preference object", }, + "UsersForgotPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersForgotPassword", + }, + }, + }, + "description": "users forgot password object", + }, "UsersListResponse": { "content": { "application/json": { @@ -4008,19 +4635,89 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` }, "description": "List of users", }, + "UsersLoginResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogin", + }, + }, + }, + "description": "users auth object", + }, + "UsersLogoutResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogout", + }, + }, + }, + "description": "users logout response", + }, + "UsersMeResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersMe", + }, + }, + }, + "description": "users me response", + }, "UsersNotFoundResponse": { "content": {}, "description": "users not found", }, + "UsersRefreshTokenResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersRefreshToken", + }, + }, + }, + "description": "users refresh token response", + }, + "UsersResetPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersResetPassword", + }, + }, + }, + "description": "users reset password response", + }, "UsersResponse": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Users", + "$ref": "#/components/schemas/Users", + }, + }, + }, + "description": "users object", + }, + "UsersUnlockResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersUnlock", + }, + }, + }, + "description": "users unlock response", + }, + "UsersVerifyResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersVerify", }, }, }, - "description": "users object", + "description": "users verify response", }, }, "schemas": { @@ -5044,6 +5741,132 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` "title": "users", "type": "object", }, + "UsersForgotPassword": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Forgot password response", + }, + "UsersLogin": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "token", + "exp", + ], + "title": "Login response", + }, + "UsersLogout": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Logout response", + }, + "UsersMe": { + "properties": { + "collection": { + "type": "string", + }, + "exp": { + "type": "number", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_strategy": { + "type": "string", + }, + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + "_strategy", + ], + "type": "object", + }, + }, + "required": [ + "user", + "collection", + "token", + "exp", + ], + "title": "Me response", + }, "UsersQueryOperations": { "properties": { "createdAt": { @@ -5361,6 +6184,114 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` "title": "users query disjunction", "type": "object", }, + "UsersRefreshToken": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "refreshedToken": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "collection": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "email", + "collection", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "refreshedToken", + "exp", + ], + "title": "Refresh token response", + }, + "UsersResetPassword": { + "properties": { + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "token", + "user", + ], + "title": "Reset password response", + }, + "UsersUnlock": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Unlock response", + }, + "UsersVerify": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Verify user response", + }, "supportedTimezones": { "example": "Europe/Prague", "type": "string", @@ -6407,38 +7338,165 @@ exports[`openapi generators > handles block editor fields correctly 1`] = ` "users", ], }, - "post": { - "operationId": "createUsers", - "parameters": [ - { - "in": "query", - "name": "depth", - "schema": { - "type": "number", - }, - }, - { - "in": "query", - "name": "locale", - "schema": { - "type": "string", - }, + "post": { + "operationId": "createUsers", + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + ], + "requestBody": { + "$ref": "#/components/requestBodies/UsersRequestBody", + }, + "responses": { + "201": { + "$ref": "#/components/responses/NewUsersResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new users", + "tags": [ + "users", + ], + }, + }, + "/api/users/forgot-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersForgotPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersForgotPasswordResponse", + }, + }, + "summary": "Forgot password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/login": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersLoginRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersLoginResponse", + }, + }, + "summary": "Log in to users", + "tags": [ + "users", + ], + }, + }, + "/api/users/logout": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersLogoutResponse", + }, + }, + "summary": "Log out of users", + "tags": [ + "users", + ], + }, + }, + "/api/users/me": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersMeResponse", + }, + }, + "summary": "Get current users", + "tags": [ + "users", + ], + }, + }, + "/api/users/refresh-token": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersRefreshTokenResponse", + }, + }, + "summary": "Refresh token for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/reset-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersResetPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersResetPasswordResponse", + }, + }, + "summary": "Reset password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/unlock": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersUnlockRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersUnlockResponse", + }, + }, + "summary": "Unlock users", + "tags": [ + "users", + ], + }, + }, + "/api/users/verify/{token}": { + "parameters": [ + { + "description": "Verification token for users", + "in": "path", + "name": "token", + "required": true, + "schema": { + "type": "string", }, - ], - "requestBody": { - "$ref": "#/components/requestBodies/UsersRequestBody", }, + ], + "post": { "responses": { - "201": { - "$ref": "#/components/responses/NewUsersResponse", + "200": { + "$ref": "#/components/responses/UsersVerifyResponse", }, }, - "security": [ - { - "ApiKey": [], - }, - ], - "summary": "Create a new users", + "summary": "Verify users", "tags": [ "users", ], @@ -6790,6 +7848,50 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` }, "description": "Payload Preference", }, + "UsersForgotPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Forgot password request", + "type": "object", + }, + }, + }, + "description": "Forgot password request for users", + }, + "UsersLoginRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "type": "string", + }, + }, + "required": [ + "email", + "password", + ], + "title": "Login request", + "type": "object", + }, + }, + }, + "description": "Login request for users", + }, "UsersPatchRequestBody": { "content": { "application/json": { @@ -6932,6 +8034,50 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` }, "description": "users", }, + "UsersResetPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "password": { + "type": "string", + }, + "token": { + "type": "string", + }, + }, + "required": [ + "token", + "password", + ], + "title": "Reset password request", + "type": "object", + }, + }, + }, + "description": "Reset password request for users", + }, + "UsersUnlockRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Unlock request", + "type": "object", + }, + }, + }, + "description": "Unlock request for users", + }, }, "responses": { "EventListResponse": { @@ -7461,6 +8607,16 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` }, "description": "Payload Preference object", }, + "UsersForgotPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersForgotPassword", + }, + }, + }, + "description": "users forgot password object", + }, "UsersListResponse": { "content": { "application/json": { @@ -7520,10 +8676,60 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` }, "description": "List of users", }, + "UsersLoginResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogin", + }, + }, + }, + "description": "users auth object", + }, + "UsersLogoutResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogout", + }, + }, + }, + "description": "users logout response", + }, + "UsersMeResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersMe", + }, + }, + }, + "description": "users me response", + }, "UsersNotFoundResponse": { "content": {}, "description": "users not found", }, + "UsersRefreshTokenResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersRefreshToken", + }, + }, + }, + "description": "users refresh token response", + }, + "UsersResetPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersResetPassword", + }, + }, + }, + "description": "users reset password response", + }, "UsersResponse": { "content": { "application/json": { @@ -7534,6 +8740,26 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` }, "description": "users object", }, + "UsersUnlockResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersUnlock", + }, + }, + }, + "description": "users unlock response", + }, + "UsersVerifyResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersVerify", + }, + }, + }, + "description": "users verify response", + }, }, "schemas": { "Event": { @@ -8560,54 +9786,180 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` "nullable": true, "type": "string", }, - "resetPasswordExpiration": { - "nullable": true, + "resetPasswordExpiration": { + "nullable": true, + "type": "string", + }, + "resetPasswordToken": { + "nullable": true, + "type": "string", + }, + "salt": { + "nullable": true, + "type": "string", + }, + "sessions": { + "items": { + "additionalProperties": false, + "properties": { + "createdAt": { + "nullable": true, + "type": "string", + }, + "expiresAt": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "expiresAt", + ], + "type": "object", + }, + "nullable": true, + "type": "array", + }, + "updatedAt": { + "type": "string", + }, + }, + "required": [ + "id", + "updatedAt", + "createdAt", + "email", + ], + "title": "users", + "type": "object", + }, + "UsersForgotPassword": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Forgot password response", + }, + "UsersLogin": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "token", + "exp", + ], + "title": "Login response", + }, + "UsersLogout": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Logout response", + }, + "UsersMe": { + "properties": { + "collection": { "type": "string", }, - "resetPasswordToken": { - "nullable": true, - "type": "string", + "exp": { + "type": "number", }, - "salt": { - "nullable": true, + "token": { "type": "string", }, - "sessions": { - "items": { - "additionalProperties": false, - "properties": { - "createdAt": { - "nullable": true, - "type": "string", - }, - "expiresAt": { - "type": "string", - }, - "id": { - "type": "string", - }, + "user": { + "additionalProperties": false, + "properties": { + "_strategy": { + "type": "string", + }, + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", }, - "required": [ - "id", - "expiresAt", - ], - "type": "object", }, - "nullable": true, - "type": "array", - }, - "updatedAt": { - "type": "string", + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + "_strategy", + ], + "type": "object", }, }, "required": [ - "id", - "updatedAt", - "createdAt", - "email", + "user", + "collection", + "token", + "exp", ], - "title": "users", - "type": "object", + "title": "Me response", }, "UsersQueryOperations": { "properties": { @@ -8926,6 +10278,114 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` "title": "users query disjunction", "type": "object", }, + "UsersRefreshToken": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "refreshedToken": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "collection": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "email", + "collection", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "refreshedToken", + "exp", + ], + "title": "Refresh token response", + }, + "UsersResetPassword": { + "properties": { + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "token", + "user", + ], + "title": "Reset password response", + }, + "UsersUnlock": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Unlock response", + }, + "UsersVerify": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Verify user response", + }, "supportedTimezones": { "example": "Europe/Prague", "type": "string", @@ -10011,6 +11471,133 @@ exports[`openapi generators > handles datetime field with timezones correctly 1` ], }, }, + "/api/users/forgot-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersForgotPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersForgotPasswordResponse", + }, + }, + "summary": "Forgot password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/login": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersLoginRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersLoginResponse", + }, + }, + "summary": "Log in to users", + "tags": [ + "users", + ], + }, + }, + "/api/users/logout": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersLogoutResponse", + }, + }, + "summary": "Log out of users", + "tags": [ + "users", + ], + }, + }, + "/api/users/me": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersMeResponse", + }, + }, + "summary": "Get current users", + "tags": [ + "users", + ], + }, + }, + "/api/users/refresh-token": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersRefreshTokenResponse", + }, + }, + "summary": "Refresh token for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/reset-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersResetPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersResetPasswordResponse", + }, + }, + "summary": "Reset password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/unlock": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersUnlockRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersUnlockResponse", + }, + }, + "summary": "Unlock users", + "tags": [ + "users", + ], + }, + }, + "/api/users/verify/{token}": { + "parameters": [ + { + "description": "Verification token for users", + "in": "path", + "name": "token", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersVerifyResponse", + }, + }, + "summary": "Verify users", + "tags": [ + "users", + ], + }, + }, "/api/users/{id}": { "delete": { "operationId": "deleteUsers", @@ -10304,14 +11891,58 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, }, "required": [ - "user", + "user", + ], + "title": "PayloadPreference", + "type": "object", + }, + }, + }, + "description": "Payload Preference", + }, + "UserForgotPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Forgot password request", + "type": "object", + }, + }, + }, + "description": "Forgot password request for User", + }, + "UserLoginRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "type": "string", + }, + }, + "required": [ + "email", + "password", ], - "title": "PayloadPreference", + "title": "Login request", "type": "object", }, }, }, - "description": "Payload Preference", + "description": "Login request for User", }, "UserPatchRequestBody": { "content": { @@ -10493,6 +12124,50 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, "description": "User", }, + "UserResetPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "password": { + "type": "string", + }, + "token": { + "type": "string", + }, + }, + "required": [ + "token", + "password", + ], + "title": "Reset password request", + "type": "object", + }, + }, + }, + "description": "Reset password request for User", + }, + "UserUnlockRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Unlock request", + "type": "object", + }, + }, + }, + "description": "Unlock request for User", + }, }, "responses": { "NewPayloadLockedDocumentResponse": { @@ -10902,6 +12577,16 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, "description": "Payload Preference object", }, + "UserForgotPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserForgotPassword", + }, + }, + }, + "description": "User forgot password object", + }, "UserListResponse": { "content": { "application/json": { @@ -10961,10 +12646,60 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, "description": "List of Users", }, + "UserLoginResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserLogin", + }, + }, + }, + "description": "User auth object", + }, + "UserLogoutResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserLogout", + }, + }, + }, + "description": "User logout response", + }, + "UserMeResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserMe", + }, + }, + }, + "description": "User me response", + }, "UserNotFoundResponse": { "content": {}, "description": "User not found", }, + "UserRefreshTokenResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserRefreshToken", + }, + }, + }, + "description": "User refresh token response", + }, + "UserResetPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserResetPassword", + }, + }, + }, + "description": "User reset password response", + }, "UserResponse": { "content": { "application/json": { @@ -10975,6 +12710,26 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, "description": "User object", }, + "UserUnlockResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserUnlock", + }, + }, + }, + "description": "User unlock response", + }, + "UserVerifyResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserVerify", + }, + }, + }, + "description": "User verify response", + }, }, "schemas": { "PayloadLockedDocument": { @@ -11739,6 +13494,132 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` "title": "User", "type": "object", }, + "UserForgotPassword": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Forgot password response", + }, + "UserLogin": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "token", + "exp", + ], + "title": "Login response", + }, + "UserLogout": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Logout response", + }, + "UserMe": { + "properties": { + "collection": { + "type": "string", + }, + "exp": { + "type": "number", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_strategy": { + "type": "string", + }, + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + "_strategy", + ], + "type": "object", + }, + }, + "required": [ + "user", + "collection", + "token", + "exp", + ], + "title": "Me response", + }, "UserQueryOperations": { "properties": { "createdAt": { @@ -12022,39 +13903,147 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` }, ], }, - "type": "array", + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "User query conjunction", + "type": "object", + }, + "UserQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/UserQueryOperations", + }, + { + "$ref": "#/components/schemas/UserQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/UserQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "User query disjunction", + "type": "object", + }, + "UserRefreshToken": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "refreshedToken": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "collection": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "email", + "collection", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "refreshedToken", + "exp", + ], + "title": "Refresh token response", + }, + "UserResetPassword": { + "properties": { + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", }, }, "required": [ - "and", + "message", + "token", + "user", ], - "title": "User query conjunction", - "type": "object", + "title": "Reset password response", }, - "UserQueryOperationsOr": { + "UserUnlock": { "properties": { - "or": { - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/UserQueryOperations", - }, - { - "$ref": "#/components/schemas/UserQueryOperationsAnd", - }, - { - "$ref": "#/components/schemas/UserQueryOperationsOr", - }, - ], - }, - "type": "array", + "message": { + "type": "string", }, }, "required": [ - "or", + "message", ], - "title": "User query disjunction", - "type": "object", + "title": "Unlock response", + }, + "UserVerify": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Verify user response", }, "supportedTimezones": { "example": "Europe/Prague", @@ -12912,6 +14901,133 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` ], }, }, + "/api/users/forgot-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UserForgotPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserForgotPasswordResponse", + }, + }, + "summary": "Forgot password for User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/login": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UserLoginRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserLoginResponse", + }, + }, + "summary": "Log in to User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/logout": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UserLogoutResponse", + }, + }, + "summary": "Log out of User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/me": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UserMeResponse", + }, + }, + "summary": "Get current User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/refresh-token": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UserRefreshTokenResponse", + }, + }, + "summary": "Refresh token for User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/reset-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UserResetPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserResetPasswordResponse", + }, + }, + "summary": "Reset password for User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/unlock": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UserUnlockRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UserUnlockResponse", + }, + }, + "summary": "Unlock User", + "tags": [ + "Users", + ], + }, + }, + "/api/users/verify/{token}": { + "parameters": [ + { + "description": "Verification token for User", + "in": "path", + "name": "token", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UserVerifyResponse", + }, + }, + "summary": "Verify User", + "tags": [ + "Users", + ], + }, + }, "/api/users/{id}": { "delete": { "operationId": "deleteUser", @@ -13252,6 +15368,50 @@ exports[`openapi generators > handles non-default collection 1`] = ` }, "description": "Post", }, + "UsersForgotPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Forgot password request", + "type": "object", + }, + }, + }, + "description": "Forgot password request for users", + }, + "UsersLoginRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "type": "string", + }, + }, + "required": [ + "email", + "password", + ], + "title": "Login request", + "type": "object", + }, + }, + }, + "description": "Login request for users", + }, "UsersPatchRequestBody": { "content": { "application/json": { @@ -13394,6 +15554,50 @@ exports[`openapi generators > handles non-default collection 1`] = ` }, "description": "users", }, + "UsersResetPasswordRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "password": { + "type": "string", + }, + "token": { + "type": "string", + }, + }, + "required": [ + "token", + "password", + ], + "title": "Reset password request", + "type": "object", + }, + }, + }, + "description": "Reset password request for users", + }, + "UsersUnlockRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + }, + "required": [ + "email", + ], + "title": "Unlock request", + "type": "object", + }, + }, + }, + "description": "Unlock request for users", + }, }, "responses": { "NewPayloadLockedDocumentResponse": { @@ -13923,6 +16127,16 @@ exports[`openapi generators > handles non-default collection 1`] = ` }, "description": "Post object", }, + "UsersForgotPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersForgotPassword", + }, + }, + }, + "description": "users forgot password object", + }, "UsersListResponse": { "content": { "application/json": { @@ -13980,21 +16194,91 @@ exports[`openapi generators > handles non-default collection 1`] = ` }, }, }, - "description": "List of users", + "description": "List of users", + }, + "UsersLoginResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogin", + }, + }, + }, + "description": "users auth object", + }, + "UsersLogoutResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersLogout", + }, + }, + }, + "description": "users logout response", + }, + "UsersMeResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersMe", + }, + }, + }, + "description": "users me response", + }, + "UsersNotFoundResponse": { + "content": {}, + "description": "users not found", + }, + "UsersRefreshTokenResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersRefreshToken", + }, + }, + }, + "description": "users refresh token response", + }, + "UsersResetPasswordResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersResetPassword", + }, + }, + }, + "description": "users reset password response", + }, + "UsersResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Users", + }, + }, + }, + "description": "users object", }, - "UsersNotFoundResponse": { - "content": {}, - "description": "users not found", + "UsersUnlockResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UsersUnlock", + }, + }, + }, + "description": "users unlock response", }, - "UsersResponse": { + "UsersVerifyResponse": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Users", + "$ref": "#/components/schemas/UsersVerify", }, }, }, - "description": "users object", + "description": "users verify response", }, }, "schemas": { @@ -14941,6 +17225,132 @@ exports[`openapi generators > handles non-default collection 1`] = ` "title": "users", "type": "object", }, + "UsersForgotPassword": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Forgot password response", + }, + "UsersLogin": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "token", + "exp", + ], + "title": "Login response", + }, + "UsersLogout": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Logout response", + }, + "UsersMe": { + "properties": { + "collection": { + "type": "string", + }, + "exp": { + "type": "number", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_strategy": { + "type": "string", + }, + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + "_strategy", + ], + "type": "object", + }, + }, + "required": [ + "user", + "collection", + "token", + "exp", + ], + "title": "Me response", + }, "UsersQueryOperations": { "properties": { "createdAt": { @@ -15258,6 +17668,114 @@ exports[`openapi generators > handles non-default collection 1`] = ` "title": "users query disjunction", "type": "object", }, + "UsersRefreshToken": { + "properties": { + "exp": { + "type": "number", + }, + "message": { + "type": "string", + }, + "refreshedToken": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "collection": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + }, + "required": [ + "id", + "email", + "collection", + ], + "type": "object", + }, + }, + "required": [ + "message", + "user", + "refreshedToken", + "exp", + ], + "title": "Refresh token response", + }, + "UsersResetPassword": { + "properties": { + "message": { + "type": "string", + }, + "token": { + "type": "string", + }, + "user": { + "additionalProperties": false, + "properties": { + "_verified": { + "type": "boolean", + }, + "createdAt": { + "format": "date-time", + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "email", + "_verified", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + }, + "required": [ + "message", + "token", + "user", + ], + "title": "Reset password response", + }, + "UsersUnlock": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Unlock response", + }, + "UsersVerify": { + "properties": { + "message": { + "type": "string", + }, + }, + "required": [ + "message", + ], + "title": "Verify user response", + }, "supportedTimezones": { "example": "Europe/Prague", "type": "string", @@ -16343,6 +18861,133 @@ exports[`openapi generators > handles non-default collection 1`] = ` ], }, }, + "/api/users/forgot-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersForgotPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersForgotPasswordResponse", + }, + }, + "summary": "Forgot password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/login": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersLoginRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersLoginResponse", + }, + }, + "summary": "Log in to users", + "tags": [ + "users", + ], + }, + }, + "/api/users/logout": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersLogoutResponse", + }, + }, + "summary": "Log out of users", + "tags": [ + "users", + ], + }, + }, + "/api/users/me": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersMeResponse", + }, + }, + "summary": "Get current users", + "tags": [ + "users", + ], + }, + }, + "/api/users/refresh-token": { + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersRefreshTokenResponse", + }, + }, + "summary": "Refresh token for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/reset-password": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersResetPasswordRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersResetPasswordResponse", + }, + }, + "summary": "Reset password for users", + "tags": [ + "users", + ], + }, + }, + "/api/users/unlock": { + "post": { + "requestBody": { + "$ref": "#/components/requestBodies/UsersUnlockRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersUnlockResponse", + }, + }, + "summary": "Unlock users", + "tags": [ + "users", + ], + }, + }, + "/api/users/verify/{token}": { + "parameters": [ + { + "description": "Verification token for users", + "in": "path", + "name": "token", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "post": { + "responses": { + "200": { + "$ref": "#/components/responses/UsersVerifyResponse", + }, + }, + "summary": "Verify users", + "tags": [ + "users", + ], + }, + }, "/api/users/{id}": { "delete": { "operationId": "deleteUsers", diff --git a/test/openapi-generators.test.ts b/test/openapi-generators.test.ts index 6f0298a..41e9b78 100644 --- a/test/openapi-generators.test.ts +++ b/test/openapi-generators.test.ts @@ -63,6 +63,14 @@ describe('openapi generators', () => { expect(new Set(Object.keys(spec.paths))).toEqual( new Set([ '/api/users', + '/api/users/forgot-password', + '/api/users/login', + '/api/users/logout', + '/api/users/me', + '/api/users/refresh-token', + '/api/users/reset-password', + '/api/users/unlock', + '/api/users/verify/{token}', '/api/users/{id}', '/api/payload-locked-documents', '/api/payload-locked-documents/{id}', @@ -95,6 +103,14 @@ describe('openapi generators', () => { '/api/posts', '/api/posts/{id}', '/api/users', + '/api/users/forgot-password', + '/api/users/login', + '/api/users/logout', + '/api/users/me', + '/api/users/refresh-token', + '/api/users/reset-password', + '/api/users/unlock', + '/api/users/verify/{token}', '/api/users/{id}', '/api/payload-locked-documents', '/api/payload-locked-documents/{id}',