Reviewer · API
OpenAPI schema conventions
When adding or modifying schemas in the OpenAPI/Swagger definitions, follow conventions already established elsewhere in the spec and avoid legacy workarounds that no longer apply. Specifically:
When adding or modifying schemas in the OpenAPI/Swagger definitions, follow conventions already established elsewhere in the spec and avoid legacy workarounds that no longer apply. Specifically:
- Prefer a direct
$refwith a siblingdescriptionfield over wrapping it inallOf— theallOfpattern was only needed to work around Swagger 2.0 limitations. Current tooling (OpenAPI 3 + our swagger generator) supports$refplus a siblingdescription, and this matches most existing definitions in the spec, e.g.:PreviousSpec: description: | The spec the service had before its most recent update. $ref: "#/components/schemas/ServiceSpec" -
Model field optionality correctly. Do not use
type: ["string", "null"](orx-nullable: true) to express that a field may be omitted from a response/request — that describes a literalnullvalue, not absence. Omittable fields should simply be left out of the schema’srequiredlist; only use nullable types when the API can genuinely return/accept an explicitnull. - Design schemas to be extensible for future variants, especially when introducing enum-like “mode” or “type” fields. Structure the schema (and the corresponding Go type) so that additional modes/options can be added later without a breaking change, e.g. reserving room for per-mode option objects alongside the discriminating enum:
type APISocketOptions struct { Access string `json:"access"` // future: per-mode option structs, e.g. PolicyOptions, keyed by "access" value }
Before adding new schema constructs, check for existing patterns in api/openapi.yaml/api/swagger.yaml and reuse them, and validate with make -C api validate-swagger after changes.</description>