diff --git a/src/openapi/generators.ts b/src/openapi/generators.ts index 49e8f21..d9d921c 100644 --- a/src/openapi/generators.ts +++ b/src/openapi/generators.ts @@ -389,6 +389,7 @@ const isOpenToPublic = async (checker: Access): Promise => { const generateCollectionOperations = async ( collection: Collection, + apiRoute: string, ): Promise> => { const { slug } = collection.config const { singular, plural } = collectionName(collection) @@ -400,7 +401,7 @@ const generateCollectionOperations = async ( } satisfies OpenAPIV3_1.ResponsesObject & OpenAPIV3.ResponsesObject return { - [`/api/${slug}`]: { + [`${apiRoute}/${slug}`]: { get: { operationId: componentName('schemas', plural, { prefix: 'list' }), summary: `Retrieve a list of ${plural}`, @@ -462,7 +463,7 @@ const generateCollectionOperations = async ( security: (await isOpenToPublic(collection.config.access.create)) ? [] : [apiKeySecurity], }, }, - [`/api/${slug}/{id}`]: { + [`${apiRoute}/${slug}/{id}`]: { parameters: [ ...baseQueryParams, { @@ -563,13 +564,14 @@ const generateGlobalSchemas = ( const generateGlobalOperations = async ( global: SanitizedGlobalConfig, + apiRoute: string, ): Promise> => { const slug = global.slug const singular = globalName(global) const tags = [singular] return { - [`/api/globals/${slug}`]: { + [`${apiRoute}/globals/${slug}`]: { get: { summary: `Get the ${singular}`, tags, @@ -663,6 +665,7 @@ export const generateV30Spec = async ( shouldIncludeCollection(collection, filters), ) const globals = req.payload.globals.config.filter(global => shouldIncludeGlobal(global, filters)) + const apiRoute = req.payload.config.routes.api const spec = { openapi: '3.0.3', @@ -670,11 +673,11 @@ export const generateV30Spec = async ( servers: [{ url: `${req.protocol}//${req.headers.get('host')}` }], paths: Object.assign( {}, - ...(await Promise.all(collections.map(generateCollectionOperations))), - ...(await Promise.all(globals.map(generateGlobalOperations))), + ...(await Promise.all(collections.map(v => generateCollectionOperations(v, apiRoute)))), + ...(await Promise.all(globals.map(v => generateGlobalOperations(v, apiRoute)))), ), components: { - securitySchemes: generateSecuritySchemes(options.authEndpoint), + securitySchemes: generateSecuritySchemes(options.authEndpoint, apiRoute), schemas: await mapValuesAsync(jsonSchemaToOpenapiSchema, schemas), requestBodies: await mapValuesAsync( async requestBody => ({ @@ -727,6 +730,7 @@ export const generateV31Spec = async ( shouldIncludeCollection(collection, filters), ) const globals = req.payload.globals.config.filter(global => shouldIncludeGlobal(global, filters)) + const apiRoute = req.payload.config.routes.api; const spec = { openapi: '3.1.0', @@ -734,11 +738,11 @@ export const generateV31Spec = async ( servers: [{ url: `${req.protocol}//${req.headers.get('host')}` }], paths: Object.assign( {}, - ...(await Promise.all(collections.map(generateCollectionOperations))), - ...(await Promise.all(globals.map(generateGlobalOperations))), + ...(await Promise.all(collections.map(v => generateCollectionOperations(v, apiRoute)))), + ...(await Promise.all(globals.map(v => generateGlobalOperations(v, apiRoute)))), ), components: { - securitySchemes: generateSecuritySchemes(options.authEndpoint), + securitySchemes: generateSecuritySchemes(options.authEndpoint, apiRoute), schemas: schemas as Record, requestBodies, responses, diff --git a/src/openapi/securitySchemes.ts b/src/openapi/securitySchemes.ts index bf654f5..fa0307b 100644 --- a/src/openapi/securitySchemes.ts +++ b/src/openapi/securitySchemes.ts @@ -4,12 +4,13 @@ export const apiKeySecurity = { ApiKey: [] } export const generateSecuritySchemes = ( tokenUrl: string, + apiRoute: string, ): Record => ({ ApiKey: { type: 'oauth2', flows: { password: { - tokenUrl: `/api/${tokenUrl}`, + tokenUrl: `${apiRoute}/${tokenUrl}`, scopes: {}, }, }, diff --git a/test/__snapshots__/openapi-generators.test.ts.snap b/test/__snapshots__/openapi-generators.test.ts.snap index f5346bc..67c9da5 100644 --- a/test/__snapshots__/openapi-generators.test.ts.snap +++ b/test/__snapshots__/openapi-generators.test.ts.snap @@ -12676,6 +12676,3350 @@ exports[`openapi generators > handles interfaceName correctly 1`] = ` } `; +exports[`openapi generators > handles non-default api route 1`] = ` +{ + "components": { + "requestBodies": { + "PayloadLockedDocumentPatchRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "document": { + "description": "ID of the posts/users", + "type": "string", + }, + "globalSlug": { + "nullable": true, + "type": "string", + }, + "user": { + "description": "ID of the users", + "type": "string", + }, + }, + "required": [], + "title": "PayloadLockedDocument", + "type": "object", + }, + }, + }, + "description": "Payload Locked Document", + }, + "PayloadLockedDocumentRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "document": { + "description": "ID of the posts/users", + "type": "string", + }, + "globalSlug": { + "nullable": true, + "type": "string", + }, + "user": { + "description": "ID of the users", + "type": "string", + }, + }, + "required": [ + "user", + ], + "title": "PayloadLockedDocument", + "type": "object", + }, + }, + }, + "description": "Payload Locked Document", + }, + "PayloadMigrationPatchRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "batch": { + "nullable": true, + "type": "number", + }, + "name": { + "nullable": true, + "type": "string", + }, + }, + "required": [], + "title": "PayloadMigration", + "type": "object", + }, + }, + }, + "description": "Payload Migration", + }, + "PayloadMigrationRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "batch": { + "nullable": true, + "type": "number", + }, + "name": { + "nullable": true, + "type": "string", + }, + }, + "required": [], + "title": "PayloadMigration", + "type": "object", + }, + }, + }, + "description": "Payload Migration", + }, + "PayloadPreferencePatchRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "key": { + "nullable": true, + "type": "string", + }, + "user": { + "description": "ID of the users", + "type": "string", + }, + "value": { + "anyOf": [ + { + "type": "object", + }, + { + "items": {}, + "type": "array", + }, + { + "type": "string", + }, + { + "type": "number", + }, + { + "type": "boolean", + }, + ], + "nullable": true, + }, + }, + "required": [], + "title": "PayloadPreference", + "type": "object", + }, + }, + }, + "description": "Payload Preference", + }, + "PayloadPreferenceRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "key": { + "nullable": true, + "type": "string", + }, + "user": { + "description": "ID of the users", + "type": "string", + }, + "value": { + "anyOf": [ + { + "type": "object", + }, + { + "items": {}, + "type": "array", + }, + { + "type": "string", + }, + { + "type": "number", + }, + { + "type": "boolean", + }, + ], + "nullable": true, + }, + }, + "required": [ + "user", + ], + "title": "PayloadPreference", + "type": "object", + }, + }, + }, + "description": "Payload Preference", + }, + "PostPatchRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "title": { + "nullable": true, + "type": "string", + }, + }, + "required": [], + "title": "Post", + "type": "object", + }, + }, + }, + "description": "Post", + }, + "PostRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "title": { + "nullable": true, + "type": "string", + }, + }, + "required": [], + "title": "Post", + "type": "object", + }, + }, + }, + "description": "Post", + }, + "UsersPatchRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "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", + }, + }, + "required": [], + "title": "User", + "type": "object", + }, + }, + }, + "description": "users", + }, + "UsersRequestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "email": { + "type": "string", + }, + "password": { + "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", + }, + }, + "required": [ + "email", + ], + "title": "User", + "type": "object", + }, + }, + }, + "description": "users", + }, + }, + "responses": { + "MutatePayloadLockedDocumentResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "doc": { + "allOf": [ + { + "$ref": "#/components/schemas/PayloadLockedDocument", + }, + { + "properties": { + "createdAt": { + "format": "date-time", + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + ], + }, + "message": { + "type": "string", + }, + }, + "required": [ + "message", + "doc", + ], + "type": "object", + }, + }, + }, + "description": "Payload Locked Document object", + }, + "MutatePayloadMigrationResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "doc": { + "allOf": [ + { + "$ref": "#/components/schemas/PayloadMigration", + }, + { + "properties": { + "createdAt": { + "format": "date-time", + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + ], + }, + "message": { + "type": "string", + }, + }, + "required": [ + "message", + "doc", + ], + "type": "object", + }, + }, + }, + "description": "Payload Migration object", + }, + "MutatePayloadPreferenceResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "doc": { + "allOf": [ + { + "$ref": "#/components/schemas/PayloadPreference", + }, + { + "properties": { + "createdAt": { + "format": "date-time", + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + ], + }, + "message": { + "type": "string", + }, + }, + "required": [ + "message", + "doc", + ], + "type": "object", + }, + }, + }, + "description": "Payload Preference object", + }, + "MutatePostResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "doc": { + "allOf": [ + { + "$ref": "#/components/schemas/Post", + }, + { + "properties": { + "createdAt": { + "format": "date-time", + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + ], + }, + "message": { + "type": "string", + }, + }, + "required": [ + "message", + "doc", + ], + "type": "object", + }, + }, + }, + "description": "Post object", + }, + "MutateUsersResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "doc": { + "allOf": [ + { + "$ref": "#/components/schemas/Users", + }, + { + "properties": { + "createdAt": { + "format": "date-time", + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "format": "date-time", + "type": "string", + }, + }, + "required": [ + "id", + "createdAt", + "updatedAt", + ], + "type": "object", + }, + ], + }, + "message": { + "type": "string", + }, + }, + "required": [ + "message", + "doc", + ], + "type": "object", + }, + }, + }, + "description": "users object", + }, + "PayloadLockedDocumentListResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "docs": { + "items": { + "$ref": "#/components/schemas/PayloadLockedDocument", + }, + "type": "array", + }, + "hasNextPage": { + "type": "boolean", + }, + "hasPrevPage": { + "type": "boolean", + }, + "limit": { + "type": "integer", + }, + "nextPage": { + "nullable": true, + "type": "integer", + }, + "page": { + "type": "integer", + }, + "pagingCounter": { + "type": "integer", + }, + "prevPage": { + "nullable": true, + "type": "integer", + }, + "totalDocs": { + "type": "integer", + }, + "totalPages": { + "type": "integer", + }, + }, + "required": [ + "docs", + "totalDocs", + "limit", + "totalPages", + "page", + "pagingCounter", + "hasPrevPage", + "hasNextPage", + "prevPage", + "nextPage", + ], + "type": "object", + }, + }, + }, + "description": "List of Payload Locked Documents", + }, + "PayloadLockedDocumentNotFoundResponse": { + "content": {}, + "description": "Payload Locked Document not found", + }, + "PayloadLockedDocumentResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PayloadLockedDocument", + }, + }, + }, + "description": "Payload Locked Document object", + }, + "PayloadMigrationListResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "docs": { + "items": { + "$ref": "#/components/schemas/PayloadMigration", + }, + "type": "array", + }, + "hasNextPage": { + "type": "boolean", + }, + "hasPrevPage": { + "type": "boolean", + }, + "limit": { + "type": "integer", + }, + "nextPage": { + "nullable": true, + "type": "integer", + }, + "page": { + "type": "integer", + }, + "pagingCounter": { + "type": "integer", + }, + "prevPage": { + "nullable": true, + "type": "integer", + }, + "totalDocs": { + "type": "integer", + }, + "totalPages": { + "type": "integer", + }, + }, + "required": [ + "docs", + "totalDocs", + "limit", + "totalPages", + "page", + "pagingCounter", + "hasPrevPage", + "hasNextPage", + "prevPage", + "nextPage", + ], + "type": "object", + }, + }, + }, + "description": "List of Payload Migrations", + }, + "PayloadMigrationNotFoundResponse": { + "content": {}, + "description": "Payload Migration not found", + }, + "PayloadMigrationResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PayloadMigration", + }, + }, + }, + "description": "Payload Migration object", + }, + "PayloadPreferenceListResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "docs": { + "items": { + "$ref": "#/components/schemas/PayloadPreference", + }, + "type": "array", + }, + "hasNextPage": { + "type": "boolean", + }, + "hasPrevPage": { + "type": "boolean", + }, + "limit": { + "type": "integer", + }, + "nextPage": { + "nullable": true, + "type": "integer", + }, + "page": { + "type": "integer", + }, + "pagingCounter": { + "type": "integer", + }, + "prevPage": { + "nullable": true, + "type": "integer", + }, + "totalDocs": { + "type": "integer", + }, + "totalPages": { + "type": "integer", + }, + }, + "required": [ + "docs", + "totalDocs", + "limit", + "totalPages", + "page", + "pagingCounter", + "hasPrevPage", + "hasNextPage", + "prevPage", + "nextPage", + ], + "type": "object", + }, + }, + }, + "description": "List of Payload Preferences", + }, + "PayloadPreferenceNotFoundResponse": { + "content": {}, + "description": "Payload Preference not found", + }, + "PayloadPreferenceResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PayloadPreference", + }, + }, + }, + "description": "Payload Preference object", + }, + "PostListResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "docs": { + "items": { + "$ref": "#/components/schemas/Post", + }, + "type": "array", + }, + "hasNextPage": { + "type": "boolean", + }, + "hasPrevPage": { + "type": "boolean", + }, + "limit": { + "type": "integer", + }, + "nextPage": { + "nullable": true, + "type": "integer", + }, + "page": { + "type": "integer", + }, + "pagingCounter": { + "type": "integer", + }, + "prevPage": { + "nullable": true, + "type": "integer", + }, + "totalDocs": { + "type": "integer", + }, + "totalPages": { + "type": "integer", + }, + }, + "required": [ + "docs", + "totalDocs", + "limit", + "totalPages", + "page", + "pagingCounter", + "hasPrevPage", + "hasNextPage", + "prevPage", + "nextPage", + ], + "type": "object", + }, + }, + }, + "description": "List of Posts", + }, + "PostNotFoundResponse": { + "content": {}, + "description": "Post not found", + }, + "PostResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Post", + }, + }, + }, + "description": "Post object", + }, + "UsersListResponse": { + "content": { + "application/json": { + "schema": { + "properties": { + "docs": { + "items": { + "$ref": "#/components/schemas/Users", + }, + "type": "array", + }, + "hasNextPage": { + "type": "boolean", + }, + "hasPrevPage": { + "type": "boolean", + }, + "limit": { + "type": "integer", + }, + "nextPage": { + "nullable": true, + "type": "integer", + }, + "page": { + "type": "integer", + }, + "pagingCounter": { + "type": "integer", + }, + "prevPage": { + "nullable": true, + "type": "integer", + }, + "totalDocs": { + "type": "integer", + }, + "totalPages": { + "type": "integer", + }, + }, + "required": [ + "docs", + "totalDocs", + "limit", + "totalPages", + "page", + "pagingCounter", + "hasPrevPage", + "hasNextPage", + "prevPage", + "nextPage", + ], + "type": "object", + }, + }, + }, + "description": "List of users", + }, + "UsersNotFoundResponse": { + "content": {}, + "description": "users not found", + }, + "UsersResponse": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Users", + }, + }, + }, + "description": "users object", + }, + }, + "schemas": { + "PayloadLockedDocument": { + "additionalProperties": false, + "properties": { + "createdAt": { + "type": "string", + }, + "document": { + "oneOf": [ + { + "additionalProperties": false, + "nullable": true, + "properties": { + "relationTo": { + "enum": [ + "posts", + ], + }, + "value": { + "oneOf": [ + { + "type": "string", + }, + { + "$ref": "#/components/schemas/Post", + }, + ], + }, + }, + "required": [ + "value", + "relationTo", + ], + "type": "object", + }, + { + "additionalProperties": false, + "nullable": true, + "properties": { + "relationTo": { + "enum": [ + "users", + ], + }, + "value": { + "oneOf": [ + { + "type": "string", + }, + { + "$ref": "#/components/schemas/Users", + }, + ], + }, + }, + "required": [ + "value", + "relationTo", + ], + "type": "object", + }, + ], + }, + "globalSlug": { + "nullable": true, + "type": "string", + }, + "id": { + "type": "string", + }, + "updatedAt": { + "type": "string", + }, + "user": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "relationTo": { + "enum": [ + "users", + ], + }, + "value": { + "oneOf": [ + { + "type": "string", + }, + { + "$ref": "#/components/schemas/Users", + }, + ], + }, + }, + "required": [ + "value", + "relationTo", + ], + "type": "object", + }, + ], + }, + }, + "required": [ + "id", + "user", + "updatedAt", + "createdAt", + ], + "title": "Payload Locked Document", + "type": "object", + }, + "PayloadLockedDocumentQueryOperations": { + "properties": { + "createdAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "globalSlug": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "updatedAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "title": "Payload Locked Document query operations", + "type": "object", + }, + "PayloadLockedDocumentQueryOperationsAnd": { + "properties": { + "and": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "Payload Locked Document query conjunction", + "type": "object", + }, + "PayloadLockedDocumentQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "Payload Locked Document query disjunction", + "type": "object", + }, + "PayloadMigration": { + "additionalProperties": false, + "properties": { + "batch": { + "nullable": true, + "type": "number", + }, + "createdAt": { + "type": "string", + }, + "id": { + "type": "string", + }, + "name": { + "nullable": true, + "type": "string", + }, + "updatedAt": { + "type": "string", + }, + }, + "required": [ + "id", + "updatedAt", + "createdAt", + ], + "title": "Payload Migration", + "type": "object", + }, + "PayloadMigrationQueryOperations": { + "properties": { + "batch": { + "properties": { + "equals": { + "type": "number", + }, + "greater_than": { + "type": "number", + }, + "greater_than_equal": { + "type": "number", + }, + "in": { + "type": "string", + }, + "less_than": { + "type": "number", + }, + "less_than_equal": { + "type": "number", + }, + "not_equals": { + "type": "number", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "createdAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "name": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "updatedAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "title": "Payload Migration query operations", + "type": "object", + }, + "PayloadMigrationQueryOperationsAnd": { + "properties": { + "and": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "Payload Migration query conjunction", + "type": "object", + }, + "PayloadMigrationQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "Payload Migration query disjunction", + "type": "object", + }, + "PayloadPreference": { + "additionalProperties": false, + "properties": { + "createdAt": { + "type": "string", + }, + "id": { + "type": "string", + }, + "key": { + "nullable": true, + "type": "string", + }, + "updatedAt": { + "type": "string", + }, + "user": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "relationTo": { + "enum": [ + "users", + ], + }, + "value": { + "oneOf": [ + { + "type": "string", + }, + { + "$ref": "#/components/schemas/Users", + }, + ], + }, + }, + "required": [ + "value", + "relationTo", + ], + "type": "object", + }, + ], + }, + "value": { + "anyOf": [ + { + "type": "object", + }, + { + "items": {}, + "type": "array", + }, + { + "type": "string", + }, + { + "type": "number", + }, + { + "type": "boolean", + }, + ], + "nullable": true, + }, + }, + "required": [ + "id", + "user", + "updatedAt", + "createdAt", + ], + "title": "Payload Preference", + "type": "object", + }, + "PayloadPreferenceQueryOperations": { + "properties": { + "createdAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "key": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "updatedAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "title": "Payload Preference query operations", + "type": "object", + }, + "PayloadPreferenceQueryOperationsAnd": { + "properties": { + "and": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "Payload Preference query conjunction", + "type": "object", + }, + "PayloadPreferenceQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "Payload Preference query disjunction", + "type": "object", + }, + "Post": { + "additionalProperties": false, + "properties": { + "createdAt": { + "type": "string", + }, + "id": { + "type": "string", + }, + "title": { + "nullable": true, + "type": "string", + }, + "updatedAt": { + "type": "string", + }, + }, + "required": [ + "id", + "updatedAt", + "createdAt", + ], + "title": "Post", + "type": "object", + }, + "PostQueryOperations": { + "properties": { + "createdAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "title": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "updatedAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "title": "Post query operations", + "type": "object", + }, + "PostQueryOperationsAnd": { + "properties": { + "and": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PostQueryOperations", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "Post query conjunction", + "type": "object", + }, + "PostQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/PostQueryOperations", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "Post query disjunction", + "type": "object", + }, + "Users": { + "additionalProperties": false, + "properties": { + "createdAt": { + "type": "string", + }, + "email": { + "type": "string", + }, + "id": { + "type": "string", + }, + "password": { + "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", + }, + "UsersQueryOperations": { + "properties": { + "createdAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "email": { + "properties": { + "contains": { + "format": "email", + "type": "string", + }, + "equals": { + "format": "email", + "type": "string", + }, + "in": { + "type": "string", + }, + "not_equals": { + "format": "email", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "hash": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "lockUntil": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "loginAttempts": { + "properties": { + "equals": { + "type": "number", + }, + "greater_than": { + "type": "number", + }, + "greater_than_equal": { + "type": "number", + }, + "in": { + "type": "string", + }, + "less_than": { + "type": "number", + }, + "less_than_equal": { + "type": "number", + }, + "not_equals": { + "type": "number", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "resetPasswordExpiration": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "resetPasswordToken": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "salt": { + "properties": { + "contains": { + "type": "string", + }, + "equals": { + "type": "string", + }, + "in": { + "type": "string", + }, + "like": { + "type": "string", + }, + "not_equals": { + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + "updatedAt": { + "properties": { + "equals": { + "format": "date-time", + "type": "string", + }, + "greater_than": { + "format": "date-time", + "type": "string", + }, + "greater_than_equal": { + "format": "date-time", + "type": "string", + }, + "in": { + "type": "string", + }, + "less_than": { + "format": "date-time", + "type": "string", + }, + "less_than_equal": { + "format": "date-time", + "type": "string", + }, + "not_equals": { + "format": "date-time", + "type": "string", + }, + "not_in": { + "type": "string", + }, + }, + "type": "object", + }, + }, + "title": "users query operations", + "type": "object", + }, + "UsersQueryOperationsAnd": { + "properties": { + "and": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/UsersQueryOperations", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "and", + ], + "title": "users query conjunction", + "type": "object", + }, + "UsersQueryOperationsOr": { + "properties": { + "or": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/UsersQueryOperations", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsOr", + }, + ], + }, + "type": "array", + }, + }, + "required": [ + "or", + ], + "title": "users query disjunction", + "type": "object", + }, + "supportedTimezones": { + "example": "Europe/Prague", + "type": "string", + }, + }, + "securitySchemes": { + "ApiKey": { + "flows": { + "password": { + "scopes": {}, + "tokenUrl": "/payload-api//payload-api/auth", + }, + }, + "type": "oauth2", + }, + }, + }, + "info": { + "title": "Test API", + "version": "1.0", + }, + "openapi": "3.0.3", + "paths": { + "/payload-api/payload-locked-documents": { + "get": { + "operationId": "listPayloadLockedDocuments", + "parameters": [ + { + "in": "query", + "name": "page", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "limit", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "globalSlug", + "-globalSlug", + "updatedAt", + "-updatedAt", + "createdAt", + "-createdAt", + ], + "type": "string", + }, + }, + { + "in": "query", + "name": "where", + "schema": { + "allOf": [ + { + "type": "object", + }, + { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadLockedDocumentQueryOperationsOr", + }, + ], + }, + ], + }, + "style": "deepObject", + }, + ], + "responses": { + "200": { + "$ref": "#/components/responses/PayloadLockedDocumentListResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Retrieve a list of Payload Locked Documents", + "tags": [ + "Payload Locked Documents", + ], + }, + "post": { + "operationId": "createPayloadLockedDocument", + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + ], + "requestBody": { + "$ref": "#/components/requestBodies/PayloadLockedDocumentRequestBody", + }, + "responses": { + "201": { + "$ref": "#/components/responses/MutatePayloadLockedDocumentResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new Payload Locked Document", + "tags": [ + "Payload Locked Documents", + ], + }, + }, + "/payload-api/payload-locked-documents/{id}": { + "delete": { + "operationId": "deletePayloadLockedDocument", + "responses": { + "200": { + "$ref": "#/components/responses/PayloadLockedDocumentResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadLockedDocumentNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Delete a Payload Locked Document", + "tags": [ + "Payload Locked Documents", + ], + }, + "get": { + "operationId": "findPayloadLockedDocumentById", + "responses": { + "200": { + "$ref": "#/components/responses/MutatePayloadLockedDocumentResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Find a Payload Locked Document by ID", + "tags": [ + "Payload Locked Documents", + ], + }, + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "description": "ID of the Payload Locked Document", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "patch": { + "operationId": "updatePayloadLockedDocument", + "requestBody": { + "$ref": "#/components/requestBodies/PayloadLockedDocumentPatchRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/PayloadLockedDocumentResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadLockedDocumentNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Update a Payload Locked Document", + "tags": [ + "Payload Locked Documents", + ], + }, + }, + "/payload-api/payload-migrations": { + "get": { + "operationId": "listPayloadMigrations", + "parameters": [ + { + "in": "query", + "name": "page", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "limit", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "name", + "-name", + "batch", + "-batch", + "updatedAt", + "-updatedAt", + "createdAt", + "-createdAt", + ], + "type": "string", + }, + }, + { + "in": "query", + "name": "where", + "schema": { + "allOf": [ + { + "type": "object", + }, + { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadMigrationQueryOperationsOr", + }, + ], + }, + ], + }, + "style": "deepObject", + }, + ], + "responses": { + "200": { + "$ref": "#/components/responses/PayloadMigrationListResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Retrieve a list of Payload Migrations", + "tags": [ + "Payload Migrations", + ], + }, + "post": { + "operationId": "createPayloadMigration", + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + ], + "requestBody": { + "$ref": "#/components/requestBodies/PayloadMigrationRequestBody", + }, + "responses": { + "201": { + "$ref": "#/components/responses/MutatePayloadMigrationResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new Payload Migration", + "tags": [ + "Payload Migrations", + ], + }, + }, + "/payload-api/payload-migrations/{id}": { + "delete": { + "operationId": "deletePayloadMigration", + "responses": { + "200": { + "$ref": "#/components/responses/PayloadMigrationResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadMigrationNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Delete a Payload Migration", + "tags": [ + "Payload Migrations", + ], + }, + "get": { + "operationId": "findPayloadMigrationById", + "responses": { + "200": { + "$ref": "#/components/responses/MutatePayloadMigrationResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Find a Payload Migration by ID", + "tags": [ + "Payload Migrations", + ], + }, + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "description": "ID of the Payload Migration", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "patch": { + "operationId": "updatePayloadMigration", + "requestBody": { + "$ref": "#/components/requestBodies/PayloadMigrationPatchRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/PayloadMigrationResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadMigrationNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Update a Payload Migration", + "tags": [ + "Payload Migrations", + ], + }, + }, + "/payload-api/payload-preferences": { + "get": { + "operationId": "listPayloadPreferences", + "parameters": [ + { + "in": "query", + "name": "page", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "limit", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "key", + "-key", + "updatedAt", + "-updatedAt", + "createdAt", + "-createdAt", + ], + "type": "string", + }, + }, + { + "in": "query", + "name": "where", + "schema": { + "allOf": [ + { + "type": "object", + }, + { + "anyOf": [ + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperations", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PayloadPreferenceQueryOperationsOr", + }, + ], + }, + ], + }, + "style": "deepObject", + }, + ], + "responses": { + "200": { + "$ref": "#/components/responses/PayloadPreferenceListResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Retrieve a list of Payload Preferences", + "tags": [ + "Payload Preferences", + ], + }, + "post": { + "operationId": "createPayloadPreference", + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + ], + "requestBody": { + "$ref": "#/components/requestBodies/PayloadPreferenceRequestBody", + }, + "responses": { + "201": { + "$ref": "#/components/responses/MutatePayloadPreferenceResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new Payload Preference", + "tags": [ + "Payload Preferences", + ], + }, + }, + "/payload-api/payload-preferences/{id}": { + "delete": { + "operationId": "deletePayloadPreference", + "responses": { + "200": { + "$ref": "#/components/responses/PayloadPreferenceResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadPreferenceNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Delete a Payload Preference", + "tags": [ + "Payload Preferences", + ], + }, + "get": { + "operationId": "findPayloadPreferenceById", + "responses": { + "200": { + "$ref": "#/components/responses/MutatePayloadPreferenceResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Find a Payload Preference by ID", + "tags": [ + "Payload Preferences", + ], + }, + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "description": "ID of the Payload Preference", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "patch": { + "operationId": "updatePayloadPreference", + "requestBody": { + "$ref": "#/components/requestBodies/PayloadPreferencePatchRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/PayloadPreferenceResponse", + }, + "404": { + "$ref": "#/components/responses/PayloadPreferenceNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Update a Payload Preference", + "tags": [ + "Payload Preferences", + ], + }, + }, + "/payload-api/posts": { + "get": { + "operationId": "listPosts", + "parameters": [ + { + "in": "query", + "name": "page", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "limit", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "title", + "-title", + "updatedAt", + "-updatedAt", + "createdAt", + "-createdAt", + ], + "type": "string", + }, + }, + { + "in": "query", + "name": "where", + "schema": { + "allOf": [ + { + "type": "object", + }, + { + "anyOf": [ + { + "$ref": "#/components/schemas/PostQueryOperations", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/PostQueryOperationsOr", + }, + ], + }, + ], + }, + "style": "deepObject", + }, + ], + "responses": { + "200": { + "$ref": "#/components/responses/PostListResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Retrieve a list of Posts", + "tags": [ + "Posts", + ], + }, + "post": { + "operationId": "createPost", + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + ], + "requestBody": { + "$ref": "#/components/requestBodies/PostRequestBody", + }, + "responses": { + "201": { + "$ref": "#/components/responses/MutatePostResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new Post", + "tags": [ + "Posts", + ], + }, + }, + "/payload-api/posts/{id}": { + "delete": { + "operationId": "deletePost", + "responses": { + "200": { + "$ref": "#/components/responses/PostResponse", + }, + "404": { + "$ref": "#/components/responses/PostNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Delete a Post", + "tags": [ + "Posts", + ], + }, + "get": { + "operationId": "findPostById", + "responses": { + "200": { + "$ref": "#/components/responses/MutatePostResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Find a Post by ID", + "tags": [ + "Posts", + ], + }, + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "description": "ID of the Post", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "patch": { + "operationId": "updatePost", + "requestBody": { + "$ref": "#/components/requestBodies/PostPatchRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/PostResponse", + }, + "404": { + "$ref": "#/components/responses/PostNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Update a Post", + "tags": [ + "Posts", + ], + }, + }, + "/payload-api/users": { + "get": { + "operationId": "listUsers", + "parameters": [ + { + "in": "query", + "name": "page", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "limit", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "updatedAt", + "-updatedAt", + "createdAt", + "-createdAt", + "email", + "-email", + "resetPasswordToken", + "-resetPasswordToken", + "resetPasswordExpiration", + "-resetPasswordExpiration", + "salt", + "-salt", + "hash", + "-hash", + "loginAttempts", + "-loginAttempts", + "lockUntil", + "-lockUntil", + ], + "type": "string", + }, + }, + { + "in": "query", + "name": "where", + "schema": { + "allOf": [ + { + "type": "object", + }, + { + "anyOf": [ + { + "$ref": "#/components/schemas/UsersQueryOperations", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsAnd", + }, + { + "$ref": "#/components/schemas/UsersQueryOperationsOr", + }, + ], + }, + ], + }, + "style": "deepObject", + }, + ], + "responses": { + "200": { + "$ref": "#/components/responses/UsersListResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Retrieve a list of users", + "tags": [ + "users", + ], + }, + "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/MutateUsersResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Create a new users", + "tags": [ + "users", + ], + }, + }, + "/payload-api/users/{id}": { + "delete": { + "operationId": "deleteUsers", + "responses": { + "200": { + "$ref": "#/components/responses/UsersResponse", + }, + "404": { + "$ref": "#/components/responses/UsersNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Delete a users", + "tags": [ + "users", + ], + }, + "get": { + "operationId": "findUsersById", + "responses": { + "200": { + "$ref": "#/components/responses/MutateUsersResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Find a users by ID", + "tags": [ + "users", + ], + }, + "parameters": [ + { + "in": "query", + "name": "depth", + "schema": { + "type": "number", + }, + }, + { + "in": "query", + "name": "locale", + "schema": { + "type": "string", + }, + }, + { + "in": "query", + "name": "fallback-locale", + "schema": { + "type": "string", + }, + }, + { + "description": "ID of the users", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "patch": { + "operationId": "updateUsers", + "requestBody": { + "$ref": "#/components/requestBodies/UsersPatchRequestBody", + }, + "responses": { + "200": { + "$ref": "#/components/responses/UsersResponse", + }, + "404": { + "$ref": "#/components/responses/UsersNotFoundResponse", + }, + }, + "security": [ + { + "ApiKey": [], + }, + ], + "summary": "Update a users", + "tags": [ + "users", + ], + }, + }, + }, + "servers": [ + { + "url": "https//localhost", + }, + ], +} +`; + exports[`openapi generators > handles non-default collection 1`] = ` { "components": { diff --git a/test/openapi-generators.test.ts b/test/openapi-generators.test.ts index f73c040..3fd3b34 100644 --- a/test/openapi-generators.test.ts +++ b/test/openapi-generators.test.ts @@ -83,6 +83,42 @@ describe('openapi generators', () => { ) }) + test('handles non-default api route', async () => { + const payload = await buildPayload({ + collections: [Posts], + routes: { + api: '/payload-api' + } + }) + + const spec = await generateV30Spec( + { protocol: 'https', headers: new Headers({ host: 'localhost' }), payload }, + { + openapiVersion: '3.0', + authEndpoint: '/payload-api/auth', + metadata: { title: 'Test API', version: '1.0' }, + filters: {}, + }, + ) + + expect(spec).toMatchSnapshot() + + expect(new Set(Object.keys(spec.paths))).toEqual( + new Set([ + '/payload-api/posts', + '/payload-api/posts/{id}', + '/payload-api/users', + '/payload-api/users/{id}', + '/payload-api/payload-locked-documents', + '/payload-api/payload-locked-documents/{id}', + '/payload-api/payload-preferences', + '/payload-api/payload-preferences/{id}', + '/payload-api/payload-migrations', + '/payload-api/payload-migrations/{id}', + ]), + ) + }) + test('handles non-default collection', async () => { const payload = await buildPayload({ collections: [Posts],