From ba99d2b73f916e598eb4336e65041be1820b3320 Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:27:58 +0530 Subject: [PATCH 1/6] format and adding variable server URL --- content/api-reference/openapi.yaml | 79 ++++++++++++++++-------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/content/api-reference/openapi.yaml b/content/api-reference/openapi.yaml index 42b87d49..4b7d2cf7 100644 --- a/content/api-reference/openapi.yaml +++ b/content/api-reference/openapi.yaml @@ -13,8 +13,16 @@ info: name: CodeCarrot email: logchimp@codecarrot.net servers: - - url: https://api..com/api/v1 - description: "" + - url: '{protocol}://{host-with-port}/api/v1' + description: "API URL" + variables: + protocol: + enum: + - 'http' + - 'https' + default: 'http' + host-with-port: + default: 'localhost:8000' tags: - name: auth description: "Endpoints related to account authentication via email and password" @@ -32,7 +40,6 @@ tags: description: "Endpoints related to roles and permissions" - name: settings description: "Endpoints related to LogChimp settings" - paths: /auth/login: post: @@ -47,7 +54,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Login' responses: - 200: + '200': description: '' content: application/json: @@ -60,7 +67,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 400: + '400': description: Bad Request content: application/json: @@ -90,7 +97,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: @@ -109,7 +116,7 @@ paths: requestBody: $ref: '#/components/requestBodies/Login' responses: - 201: + '201': description: '' content: application/json: @@ -122,7 +129,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 400: + '400': description: Bad Request content: application/json: @@ -150,12 +157,12 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - security: [ ] + security: [] /auth/setup: get: tags: @@ -167,7 +174,7 @@ paths: - $ref: '#/components/parameters/contentTypeJson' - $ref: '#/components/parameters/origin' responses: - 200: + '200': description: '' content: application/json: @@ -180,7 +187,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: @@ -213,7 +220,7 @@ paths: example: "Mike" required: true responses: - 200: + '200': description: '' content: application/json: @@ -226,7 +233,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 400: + '400': description: Bad Request content: application/json: @@ -254,7 +261,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: @@ -300,7 +307,7 @@ paths: type: object required: false responses: - 200: + '200': description: "" content: application/json: @@ -315,12 +322,12 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - security: [ ] + security: [] /auth/email/verify: post: tags: @@ -346,7 +353,7 @@ paths: example: "mike@example.com" required: true responses: - 200: + '200': description: '' content: application/json: @@ -362,7 +369,7 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 400: + '400': description: Bad Request content: application/json: @@ -376,12 +383,12 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - 500: + '500': $ref: "#/components/responses/InternalServerError" headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - security: [ ] + security: [] components: headers: contentTypeJson: @@ -408,8 +415,8 @@ components: UserBlockedErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -420,8 +427,8 @@ components: InvalidUserIdErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -432,8 +439,8 @@ components: UserNotFoundErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -444,8 +451,8 @@ components: EmailInvalidErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -456,8 +463,8 @@ components: EmailVerifiedErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -468,8 +475,8 @@ components: MailConfigurationErrorCode: type: object required: - - message - - code + - message + - code properties: message: type: string @@ -483,7 +490,7 @@ components: boardId: type: string format: uuid - example: + example: 11c14790-b4d3-4689-942c-55548cfdd8a6 name: type: string example: "🔗 Integrations" @@ -499,7 +506,7 @@ components: format: date-time BoardDetail: allOf: - - $ref: "#/components/schemas/Board" + - $ref: "#/components/schemas/Board" - type: object properties: post_count: From bfc63385891b393ef9ca040b05c1d171323ca046 Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:28:53 +0530 Subject: [PATCH 2/6] removed requestBody from GET all boards --- content/api-reference/openapi.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/content/api-reference/openapi.yaml b/content/api-reference/openapi.yaml index 4b7d2cf7..dad42676 100644 --- a/content/api-reference/openapi.yaml +++ b/content/api-reference/openapi.yaml @@ -299,13 +299,6 @@ paths: type: string default: application/json description: "" - requestBody: - description: Get all the boards - content: - application/json: - schema: - type: object - required: false responses: '200': description: "" From 57dc4ec099fe0c6e1dad8ad73f19c19b156a047e Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 13:48:04 +0530 Subject: [PATCH 3/6] add CORS support for api-reference --- src/app/api-reference/[[...slug]]/page.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/api-reference/[[...slug]]/page.tsx b/src/app/api-reference/[[...slug]]/page.tsx index 3b41f8a6..956e87a0 100644 --- a/src/app/api-reference/[[...slug]]/page.tsx +++ b/src/app/api-reference/[[...slug]]/page.tsx @@ -13,6 +13,10 @@ import { Alert } from "@/src/components/Alert"; import { openApiSource } from "@/src/lib/source"; import { openapi } from "@/src/lib/openapi"; +export const { GET, HEAD, PUT, POST, PATCH, DELETE } = openapi.createProxy({ + allowedOrigins: ["*"], +}); + export default async function Page(props: { params: Promise<{ slug?: string[] }>; }) { From 457734991b6ebb9f78047a1ec14b0809755239e2 Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 14:33:08 +0530 Subject: [PATCH 4/6] refactor and add authorization --- content/api-reference/openapi.yaml | 38 ++++++------------------------ 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/content/api-reference/openapi.yaml b/content/api-reference/openapi.yaml index dad42676..50ec4736 100644 --- a/content/api-reference/openapi.yaml +++ b/content/api-reference/openapi.yaml @@ -23,6 +23,8 @@ servers: default: 'http' host-with-port: default: 'localhost:8000' +security: + - bearerAuth: [] tags: - name: auth description: "Endpoints related to account authentication via email and password" @@ -48,9 +50,6 @@ paths: summary: Login description: 'Login to account using email and password.' operationId: userSignin - parameters: - - $ref: '#/components/parameters/contentTypeJson' - - $ref: '#/components/parameters/origin' requestBody: $ref: '#/components/requestBodies/Login' responses: @@ -110,9 +109,6 @@ paths: summary: Sign up description: Create a new user account. operationId: userSignup - parameters: - - $ref: '#/components/parameters/contentTypeJson' - - $ref: '#/components/parameters/origin' requestBody: $ref: '#/components/requestBodies/Login' responses: @@ -170,9 +166,6 @@ paths: summary: Site setup description: 'Get site setup information.' operationId: getSiteSetup - parameters: - - $ref: '#/components/parameters/contentTypeJson' - - $ref: '#/components/parameters/origin' responses: '200': description: '' @@ -199,9 +192,6 @@ paths: summary: Site setup description: 'Setup the site by creating the owner account.' operationId: siteSetup - parameters: - - $ref: '#/components/parameters/contentTypeJson' - - $ref: '#/components/parameters/origin' requestBody: description: '' content: @@ -330,9 +320,6 @@ paths: Send a verification email to the user email address. The email is only sent if have configured [SMTP mail server](https://docs.logchimp.codecarrot.net/docs/environment-variables#mail) are configured at the time of deploying LogChimp. operationId: sendVerificationEmail - parameters: - - $ref: '#/components/parameters/contentTypeJson' - - $ref: '#/components/parameters/origin' requestBody: description: '' content: @@ -381,29 +368,18 @@ paths: headers: Content-Type: $ref: '#/components/headers/contentTypeJson' - security: [] components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + description: JWT Bearer token authentication headers: contentTypeJson: description: '' schema: type: string example: application/json - parameters: - contentTypeJson: - name: Content-Type - in: header - schema: - type: string - default: application/json - description: '' - origin: - name: origin - in: header - schema: - type: string - default: 'https://example.com' - description: '' schemas: UserBlockedErrorCode: type: object From f5f34a7a9697179aeb053c32c201f3e4b3fdd9cb Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 14:38:27 +0530 Subject: [PATCH 5/6] remove request body for 'POST /auth/email/verify' --- content/api-reference/openapi.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/content/api-reference/openapi.yaml b/content/api-reference/openapi.yaml index 50ec4736..cff12b70 100644 --- a/content/api-reference/openapi.yaml +++ b/content/api-reference/openapi.yaml @@ -320,18 +320,6 @@ paths: Send a verification email to the user email address. The email is only sent if have configured [SMTP mail server](https://docs.logchimp.codecarrot.net/docs/environment-variables#mail) are configured at the time of deploying LogChimp. operationId: sendVerificationEmail - requestBody: - description: '' - content: - application/json: - schema: - type: object - properties: - email: - type: string - format: email - example: "mike@example.com" - required: true responses: '200': description: '' From 53e900ef908aadcc911aa22c0483ce13e01a01ec Mon Sep 17 00:00:00 2001 From: Ja4V8s28Ck <66721411+Ja4V8s28Ck@users.noreply.github.com> Date: Thu, 18 Sep 2025 21:03:56 +0530 Subject: [PATCH 6/6] fix --- next.config.mjs | 9 +++++---- src/app/api-reference/[[...slug]]/page.tsx | 4 ---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index 07198960..38108e86 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -9,6 +9,7 @@ const config = { // Reduce bundle size by optimizing package imports for lucide-react optimizePackageImports: ["lucide-react"], }, + allowedDevOrigins: ["localhost"], async redirects() { return [ { @@ -19,10 +20,10 @@ const config = { ]; }, - images: { - // Use Cloudflare Image Resizing instead of bundling image optimization - unoptimized: true, - }, + images: { + // Use Cloudflare Image Resizing instead of bundling image optimization + unoptimized: true, + }, }; export default withMDX(config); diff --git a/src/app/api-reference/[[...slug]]/page.tsx b/src/app/api-reference/[[...slug]]/page.tsx index 956e87a0..3b41f8a6 100644 --- a/src/app/api-reference/[[...slug]]/page.tsx +++ b/src/app/api-reference/[[...slug]]/page.tsx @@ -13,10 +13,6 @@ import { Alert } from "@/src/components/Alert"; import { openApiSource } from "@/src/lib/source"; import { openapi } from "@/src/lib/openapi"; -export const { GET, HEAD, PUT, POST, PATCH, DELETE } = openapi.createProxy({ - allowedOrigins: ["*"], -}); - export default async function Page(props: { params: Promise<{ slug?: string[] }>; }) {