Skip to content

OpenAPI support #6

@tom-nash

Description

@tom-nash

The API contract between cordon-cli and cordon-web is currently implicit: Go structs on one side, TypeScript types on the other. Changes on either side can silently break sync. We should define the contract as an OpenAPI 3.1 spec and generate types for both repos.

Endpoints in scope

POST /api/v1/auth/device, POST /auth/token, POST /auth/revoke, GET /auth/me
GET /api/v1/perimeters/lookup
GET/POST /api/v1/perimeters/{perimeterId}/policy/events
POST /api/v1/perimeters/{perimeterId}/data/ingest
Proposed approach

Write openapi.yaml spec covering all sync-facing endpoints (request/response schemas, error shapes)
Use
oapi-codegen
to generate Go types (and optionally a client) in cordon-cli
Wire generated types into the existing sync code (cli/cmd/sync.go, cli/internal/policysync/, cli/internal/api/client.go)
CI check to verify generated code stays in sync with the spec

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions