-
Notifications
You must be signed in to change notification settings - Fork 0
Add OpenAPI 3.1 specification and Scalar UI documentation #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…e updates Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces internal API documentation using an OpenAPI 3.1 spec plus a Scalar-powered interactive UI, and adds a simple health check endpoint and related tooling. It focuses on documenting existing auth/sync endpoints, wiring up a browsable /api-docs route, and validating the spec with Redocly.
Changes:
- Added a
/api/healthendpoint returning a simple JSON health status with app version and timestamp. - Introduced a
/api-docsroute using@scalar/nextjs-api-referenceto render interactive API docs backed bypublic/api-docs/openapi.yaml. - Created an OpenAPI 3.1 specification for
POST /api/auth/save-token,GET /api/cron/sync, andGET /api/health, and wired up@redocly/cliplus adocs:validatenpm script; updated dependencies/lockfile accordingly.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/app/api/health/route.ts |
Adds a dynamic health check route returning status, version, and timestamp for monitoring and uptime checks. |
src/app/api-docs/route.ts |
Exposes the Scalar API reference UI at /api-docs, configured to load the OpenAPI spec from /api-docs/openapi.yaml with the desired theme and layout. |
public/api-docs/openapi.yaml |
Defines the OpenAPI 3.1 spec, including metadata, security schemes, shared error schemas, and detailed documentation for the auth, sync, and health endpoints. |
package.json |
Adds @scalar/nextjs-api-reference and @redocly/cli dependencies and a docs:validate script to lint the OpenAPI spec. |
package-lock.json |
Updates the lockfile to pin all new transitive dependencies introduced by Scalar and Redocly tooling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update Rate Limit Description Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Rate Limit Description Update Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@devakesu Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Unable to merge, commits by you are unverified. |
I don't have access to GPG keys to sign commits in this environment. The commits are made through the To resolve this, you have two options:
Alternatively, you can squash and merge the PR, which will create a new signed commit when you merge it through GitHub's UI (if you have commit signing enabled on your account). |
Original prompt
🎯 Objective
Add comprehensive API documentation for all internal endpoints using OpenAPI 3.1 specification and Scalar UI (modern alternative to Swagger UI). This improves developer experience, enables API testing directly from the browser, and provides clear documentation for authentication, rate limiting, and error handling.
📋 Requirements
1. Create OpenAPI Specification
File:
public/api-docs/openapi.yamlCreate a complete OpenAPI 3.1 specification documenting all internal API endpoints:
Endpoints to Document:
Authentication:
POST /api/auth/save-token- Save EzyGo authentication tokenSync:
GET /api/cron/sync- Sync attendance data with EzyGo (supports both cron jobs and authenticated users)Contact:
POST /api/contact(if exists as API route, otherwise document the server action pattern)Health:
GET /api/health- Health check endpoint (needs to be created)Requirements for Each Endpoint:
/api/cron/sync?username=)Schema Components:
Error- Standard error responseValidationError- Validation error with field-level detailsRateLimitError- Rate limit exceeded errorSecurity Schemes:
BearerAuth- For CRON_SECRET (cron jobs)SupabaseAuth- For session cookies (authenticated users)Metadata:
2. Create API Documentation Page
File:
src/app/api-docs/page.tsx@scalar/nextjs-api-referencefor modern, interactive API docs3. Create Health Check Endpoint
File:
src/app/api/health/route.tsSimple health check endpoint that returns:
{ "status": "ok", "version": "1.0.0", "timestamp": "2026-01-24T12:00:00Z" }4. Install Required Dependencies
Add to
package.json:{ "dependencies": { "@scalar/nextjs-api-reference": "^0.3.0" }, "devDependencies": { "@redocly/cli": "^1.10.0" }, "scripts": { "docs:validate": "npx @redocly/cli lint public/api-docs/openapi.yaml" } }5. Update Navigation (Optional Enhancement)
If there's a developer/admin section in the navbar, add a link:
Note: Only add if there's an appropriate place in existing navigation. Don't create new navigation structure.
🎨 OpenAPI Specification Requirements
Structure:
Example Endpoint Documentation: