Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,40 @@ jobs:
web:
name: Web
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/web

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: apps/api/uv.lock

- name: Export OpenAPI schema
working-directory: apps/api
run: uv sync --frozen && uv run python export_schema.py

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: apps/web/package-lock.json

- run: npm ci
- name: Install dependencies
working-directory: apps/web
run: npm ci

- run: npm run lint
- name: Generate API client
working-directory: apps/web
run: npm run codegen

- run: npm run build
- name: Lint
working-directory: apps/web
run: npm run lint

- name: Build
working-directory: apps/web
run: npm run build

api:
name: API
Expand Down
12 changes: 12 additions & 0 deletions apps/api/export_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Export the OpenAPI schema to a JSON file for client codegen."""

import json
from pathlib import Path

from main import app

schema = app.openapi()
out = Path(__file__).resolve().parent.parent.parent / "docs" / "schema" / "openapi.json"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(schema, indent=2) + "\n")
print(f"Schema written to {out}")
3 changes: 3 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# generated api client
/src/api
2 changes: 2 additions & 0 deletions apps/web/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const eslintConfig = defineConfig([
"out/**",
"build/**",
"next-env.d.ts",
// Generated API client
"src/api/**",
]),
]);

Expand Down
10 changes: 10 additions & 0 deletions apps/web/openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
input: "../../docs/schema/openapi.json",
output: {
path: "src/api",
format: "prettier",
},
plugins: ["@hey-api/client-fetch"],
});
Loading
Loading