Skip to content

fix: openapi-ts#7

Merged
TheRealDarkCoder merged 4 commits into
developfrom
chore/cla-test
Mar 31, 2026
Merged

fix: openapi-ts#7
TheRealDarkCoder merged 4 commits into
developfrom
chore/cla-test

Conversation

@TheRealDarkCoder
Copy link
Copy Markdown
Owner

What changed
Added codegen support so frontend types and docs/schema are auto generated from openapi of fastapi.

Checklist

  • Linked issue above
  • docker compose up works locally
  • Tests added or existing tests cover this (or N/A)
  • Migration included if schema changed
  • schema.dbml updated if schema changed
  • Codegen re-run if API routes or schemas changed

Copilot AI review requested due to automatic review settings March 31, 2026 22:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 31, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@TheRealDarkCoder
Copy link
Copy Markdown
Owner Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Mar 31, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an OpenAPI-driven code generation flow so the FastAPI schema can be exported and the Next.js frontend can generate API client/types from that schema.

Changes:

  • Add apps/api/export_schema.py to write FastAPI’s OpenAPI to docs/schema/openapi.json.
  • Add @hey-api/openapi-ts config + web codegen script and ignore generated output under apps/web/src/api.
  • Update CI (web job) to export the schema and run codegen before lint/build.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package.json Updates root codegen script to use npm in apps/web.
docs/schema/openapi.json Adds exported OpenAPI schema artifact (initial content includes /health).
apps/web/package.json Adds codegen script and hey-api devDependencies for OpenAPI TS generation.
apps/web/package-lock.json Locks new hey-api dependencies introduced for codegen.
apps/web/openapi-ts.config.ts Configures openapi-ts input (docs/schema/openapi.json) and output (src/api).
apps/web/.gitignore Ignores generated API client directory src/api.
apps/api/export_schema.py Adds script to export schema from FastAPI app to docs/schema/openapi.json.
.github/workflows/ci.yml Runs schema export + web codegen before lint/build in the web CI job.
Files not reviewed (1)
  • apps/web/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines 4 to 6
"scripts": {
"codegen": "cd apps/web && pnpm run codegen"
"codegen": "cd apps/web && npm run codegen"
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run codegen only runs the web codegen step; it doesn't regenerate docs/schema/openapi.json first. That means local codegen can easily run against a stale schema (CI updates the schema, but this script won’t). Consider chaining the schema export step here (e.g., run the API export script first) so codegen is reproducible locally.

Copilot uses AI. Check for mistakes.
Comment thread apps/web/package.json
Comment on lines 6 to 11
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
"lint": "eslint",
"codegen": "openapi-ts"
},
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated client is written to src/api (and is gitignored), but npm run build doesn’t run codegen. If/when the app starts importing the generated client, Docker/local builds that only run npm run build will fail unless codegen is run beforehand. Consider adding a prebuild step or folding codegen into the build pipeline to ensure src/api exists whenever building.

Copilot uses AI. Check for mistakes.
Comment thread apps/web/package.json
"react-dom": "19.2.4"
},
"devDependencies": {
"@hey-api/client-fetch": "^0.13.1",
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hey-api/client-fetch is marked deprecated in the lockfile (bundled into @hey-api/openapi-ts as of v0.73.0). Unless you specifically need it as a separate dependency, consider removing it to avoid deprecation warnings and reduce dependencies.

Suggested change
"@hey-api/client-fetch": "^0.13.1",

Copilot uses AI. Check for mistakes.
Comment thread docs/schema/openapi.json
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /health 200 response schema is {} in the exported OpenAPI spec, which will cause generated TypeScript types for this endpoint to be effectively untyped. If the goal is strongly typed clients, consider adding a response_model (or explicit response schema) on the FastAPI route so the exported OpenAPI contains the object shape.

Suggested change
"schema": {}
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "ok"
}
},
"required": [
"status"
]
}

Copilot uses AI. Check for mistakes.
@TheRealDarkCoder TheRealDarkCoder merged commit 1518cd1 into develop Mar 31, 2026
4 checks passed
@TheRealDarkCoder TheRealDarkCoder deleted the chore/cla-test branch March 31, 2026 22:39
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants