Gredice api reference
Use for Gredice API docs/contracts: Hono routes, OpenAPI/Scalar, auth/security, validation schemas, generated directory types, and client helpers.From its SKILL.md
npx -y skills add gredice/gredice --skill gredice-api-referenceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.4 KB, as published. Nobody here has run it
Gredice API Reference
Overview
Keep API reference behavior aligned with route implementation, validation, auth, and generated TypeScript contracts. Treat docs metadata as part of the API surface.
Current API Shape
Primary files and ownership:
- Route composition:
apps/api/app/api/[...route]/route.ts. - Hono route modules:
apps/api/app/api/[...route]/*Routes.tsand nesteddata/*Routes.ts. - Scalar page:
apps/api/app/docs/[slug]/page.tsx. - OpenAPI helper for directory/CMS docs:
apps/api/lib/docs/openApiDocs.ts. - API docs tests:
apps/api/lib/docs/openApiDocs.node.spec.ts. - Security helpers:
apps/api/lib/docs/security.ts. - Public directory type package:
packages/directory-types. - Client helper:
packages/client/src/directories-api.ts.
The API app uses Hono, hono-openapi, Zod validators, and Next.js App Router route handlers. The reference UI reads /api/docs/{slug} specs through Scalar.
Route Documentation Workflow
When adding or changing an API endpoint:
- Read the route implementation and validators before editing docs.
- Ensure
describeRoutedescribes the actual behavior, not intended future behavior. - Keep
securityaccurate:- Use
authSecurityfor endpoints that require session cookie or bearer token. - Use
publicSecurityfor intentionally public endpoints. - Use explicit mixed security only when the route supports both public and authenticated access.
- Use
- Keep
tagsconsistent within the route group when tags are already used. - Add request validators with
zValidatorbefore relying on values from params, query, or JSON bodies. - Document status codes only when the route really returns them.
- For auth, account, payment, delivery, inventory, and private data endpoints, verify the server-side authorization path, not just the documented security scheme.
Directory And CMS OpenAPI
apps/api/lib/docs/openApiDocs.ts builds OpenAPI 3.1 docs for directory entities and CMS pages.
Respect these details:
- Entity schemas come from
@gredice/storageentity types and attribute definitions. - Attribute
dataTypecontrols the OpenAPI schema. Unsupported types should fail loudly throughUnsupportedCmsAttributeDataTypeError. json|...,ref:...,range, andrange|...data types have custom handling.- CMS page docs include
/pagesand/pages/{slug}. imageis a shared component schema.- Tests in
openApiDocs.node.spec.tsshould cover parser and schema behavior when this logic changes.
Do not hand-edit generated packages/directory-types/src/v1.d.ts or apps/api/lib/@types/directories-api/v1.d.ts without regenerating from the API docs source.
Generated Type Contracts
When API docs affect generated clients:
packages/directory-typesre-exports OpenAPIpathsandcomponentsfromsrc/v1.d.ts.packages/client/src/directories-api.tsbuilds anopenapi-fetchclient from those generated types.- Run
pnpm --filter @gredice/directory-types regenerateafter CMS entity types or public directory API docs change. - Use
pnpm --filter @gredice/directory-types regenerate:cms-typesonly whensrc/v1.d.tsis already current. apps/apialso haspnpm --filter api regenerate:directories-apifor its local generated type.
Description Quality
Write API descriptions that help consumers call the endpoint:
- State the resource and actor, for example "Get delivery requests for the current user".
- Include lifecycle or side effects for mutations, for example notifications, Stripe sessions, account switching, or cache invalidation.
- Avoid generic descriptions like "Change notification" when the route is more specific.
- Keep examples and defaults grounded in validators and returned data.
- Do not expose secret names, internal stack traces, private IDs, or webhook payload details unless they are part of the public contract.
Validation
Choose the smallest api test/build check that covers the route or docs change. Regenerate and lint @gredice/directory-types only when public directory/CMS API docs affect generated contracts. For visual API reference changes, start the API app and inspect the relevant /docs/{slug} page.
Only query a live API or database when source code and tests cannot answer whether a documented response matches production data.