From 7cb174b6444efdc7ace0b524328a650a570208aa Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Thu, 25 Jul 2024 14:53:41 -0700 Subject: [PATCH] Add descriptions for list cas/certs endpoints --- backend/src/lib/api-docs/constants.ts | 15 +++++++++++++ .../src/server/routes/v2/project-router.ts | 22 +++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts index c0e59b2b6..5e5e330e1 100644 --- a/backend/src/lib/api-docs/constants.ts +++ b/backend/src/lib/api-docs/constants.ts @@ -425,6 +425,21 @@ export const PROJECTS = { }, LIST_INTEGRATION_AUTHORIZATION: { workspaceId: "The ID of the project to list integration auths for." + }, + LIST_CAS: { + slug: "The slug of the project to list CAs for.", + status: "The status of the CA to filter by.", + friendlyName: "The friendly name of the CA to filter by.", + commonName: "The common name of the CA to filter by.", + offset: "The offset to start from. If you enter 10, it will start from the 10th CA.", + limit: "The number of CAs to return." + }, + LIST_CERTIFICATES: { + slug: "The slug of the project to list certificates for.", + friendlyName: "The friendly name of the certificate to filter by.", + commonName: "The common name of the certificate to filter by.", + offset: "The offset to start from. If you enter 10, it will start from the 10th certificate.", + limit: "The number of certificates to return." } } as const; diff --git a/backend/src/server/routes/v2/project-router.ts b/backend/src/server/routes/v2/project-router.ts index 76286c833..e59291664 100644 --- a/backend/src/server/routes/v2/project-router.ts +++ b/backend/src/server/routes/v2/project-router.ts @@ -317,14 +317,14 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => { }, schema: { params: z.object({ - slug: slugSchema.describe("The slug of the project to list CAs.") + slug: slugSchema.describe(PROJECTS.LIST_CAS.slug) }), querystring: z.object({ - status: z.enum([CaStatus.ACTIVE, CaStatus.PENDING_CERTIFICATE]).optional(), - friendlyName: z.string().optional(), - commonName: z.string().optional(), - offset: z.coerce.number().min(0).max(100).default(0), - limit: z.coerce.number().min(1).max(100).default(25) + status: z.enum([CaStatus.ACTIVE, CaStatus.PENDING_CERTIFICATE]).optional().describe(PROJECTS.LIST_CAS.status), + friendlyName: z.string().optional().describe(PROJECTS.LIST_CAS.friendlyName), + commonName: z.string().optional().describe(PROJECTS.LIST_CAS.commonName), + offset: z.coerce.number().min(0).max(100).default(0).describe(PROJECTS.LIST_CAS.offset), + limit: z.coerce.number().min(1).max(100).default(25).describe(PROJECTS.LIST_CAS.limit) }), response: { 200: z.object({ @@ -358,13 +358,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => { }, schema: { params: z.object({ - slug: slugSchema.describe("The slug of the project to list certificates.") + slug: slugSchema.describe(PROJECTS.LIST_CERTIFICATES.slug) }), querystring: z.object({ - friendlyName: z.string().optional(), - commonName: z.string().optional(), - offset: z.coerce.number().min(0).max(100).default(0), - limit: z.coerce.number().min(1).max(100).default(25) + friendlyName: z.string().optional().describe(PROJECTS.LIST_CERTIFICATES.friendlyName), + commonName: z.string().optional().describe(PROJECTS.LIST_CERTIFICATES.commonName), + offset: z.coerce.number().min(0).max(100).default(0).describe(PROJECTS.LIST_CERTIFICATES.offset), + limit: z.coerce.number().min(1).max(100).default(25).describe(PROJECTS.LIST_CERTIFICATES.limit) }), response: { 200: z.object({