Build spec-first docs site and contract enforcement pipeline#5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88c95f90ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
scripts/contract-test.sh
Outdated
| } | ||
| trap cleanup EXIT | ||
|
|
||
| sleep 2 |
There was a problem hiding this comment.
Wait for server readiness before invoking Schemathesis
The contract test starts cargo run --release in the background and then uses a fixed sleep 2 before running Schemathesis, which is too short on fresh CI runners where the binary still needs to compile; in this repository’s runtime-contract job there is no cargo cache step, so Schemathesis can run before port 8080 is listening and fail with connection errors. Replace the fixed delay with an explicit readiness loop (e.g., poll /now or the socket) before starting the test run.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 016d424. Replaced fixed sleep with a readiness loop that polls /now for up to 60s before running Schemathesis, and prints server logs if startup never succeeds.
web/src/pages/api.astro
Outdated
| import docsModel from "../generated/docs-model.json"; | ||
| import { buildCurlPreview, fieldConfigForParameter } from "../lib/api-tester"; | ||
|
|
||
| const apiBase = import.meta.env.PUBLIC_API_BASE_URL ?? "http://localhost:8080"; |
There was a problem hiding this comment.
Use same-origin API base for interactive docs by default
The API docs page defaults apiBase to http://localhost:8080, but the Astro site is served from a different origin during normal dev/preview runs, so the in-browser fetch requests become cross-origin and are blocked unless the backend is configured for CORS. Because the backend currently does not add CORS headers, the “Send request” flow is non-functional out of the box; defaulting to a relative URL (or documenting/providing a proxy/CORS config) avoids this breakage.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 016d424. The API docs now default to same-origin (PUBLIC_API_BASE_URL fallback is empty), so browser requests work without CORS setup by default. Curl previews also render relative URLs in same-origin mode.
Summary
openapi.yamlas the single source of truth by generating web artifacts and a Rust contract crate used by backend compile-time checksTest Plan
cargo test --all-targets --all-features./scripts/generate-all.shnpm run test:unit(inweb/)npm run test:a11y(inweb/)npm run build(inweb/)