Implement Bookings API from OpenAPI Spec
Hand Opulent a YAML spec and get fully implemented route handlers, validation, and integration tests, matching your existing codebase patterns.
Read the spec and existing API patterns
Connect GitHub and Postman. Postman holds the OpenAPI spec or lets you import it; GitHub holds the existing code. Opulent reads the spec paths and schemas, then reads the reference routes under src/api/v2/users/ to match conventions.
The task is framed as a playbook, a reusable, named set of steps Opulent follows every time you hand it a new spec.
Playbook: !openapi-to-api For a given OpenAPI spec: 1. Read the spec and extract every path, method, parameter, and schema for the target resource. 2. Read the existing reference routes to match folder structure, middleware, error handling, and test patterns. 3. For each endpoint, create route handler, validation schema, and service call. 4. Write integration tests for success, validation errors, auth failures, and edge cases. 5. Run npm test and npm run typecheck. 6. Iterate until green, then open a PR.
Point Opulent at the best-maintained resource in your API as the reference. Copying the patterns of a working endpoint reduces the chance that the new endpoints break existing conventions.
Map the spec to code
Opulent extracts the paths and schemas from openapi/bookings-v2.yaml and maps them to your stack. For each endpoint, it decides which file to create or modify and how the validation schema should match the spec.
The prompt is specific about the resource and the reference folder. The spec gives the contract; the reference folder gives the conventions.
Spec excerpt: openapi/bookings-v2.yaml GET /api/v2/bookings - query: page, startDate, endDate - response: BookingListResponse POST /api/v2/bookings - body: CreateBookingInput - response: 201 or 409 conflict GET /api/v2/bookings/:id PATCH /api/v2/bookings/:id DELETE /api/v2/bookings/:id (soft delete) POST /api/v2/bookings/:id/confirm (200 or 422) POST /api/v2/bookings/:id/cancel CreateBookingInput: title: string, maxLength 200 startTime: date-time endTime: date-time roomId: uuid notes: string, maxLength 1000, optional
Implement, test, and iterate
Opulent creates the route handlers, Zod schemas, and service calls, then writes Supertest integration tests for every endpoint. It runs the tests and fixes failures until the suite is green.
The requirement is not to open a PR until everything passes end to end. This keeps review focused on the spec and conventions, not on debugging failing tests.
Files created: - src/api/v2/bookings/routes.ts - src/api/v2/bookings/validation.ts (Zod schemas) - src/api/v2/bookings/service.ts - src/api/v2/bookings/__tests__/bookings.test.ts Tests covered: - GET list with pagination - POST create with conflict - GET /:id - PATCH partial update - DELETE soft delete - POST /:id/confirm and /cancel - Validation errors (missing fields, bad UUID) - Auth failures
Deploy and verify
After the PR is merged, deploy to Vercel or your staging environment. Use Postman to hit the new endpoints against the deployed app and confirm the spec contract holds in production.
The integration tests are the first proof; the live Postman smoke test is the second. Both are easier when the spec was the source of truth from the start.
Sharpen the spec-to-code loop
When the next spec comes in, reuse the !openapi-to-api playbook with the new YAML path and reference folder. Update the playbook with any stack-specific conventions Opulent missed this time.
If a spec change arrives, have Opulent diff the YAML against the existing code and update only the affected routes, tests, and schemas.
The natural chain: when the API needs load testing, use Click-Test Real Product Flows with Computer Use; when it needs monitoring, use Daily Datadog Health Digest; when it changes an existing contract, use Migrate 50 Files from REST to GraphQL.