Awesome Reviewers

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:

Instruction

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:

  1. Prefer a direct $ref with a sibling description field over wrapping it in allOf — the allOf pattern was only needed to work around Swagger 2.0 limitations. Current tooling (OpenAPI 3 + our swagger generator) supports $ref plus a sibling description, 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"
    
  2. Model field optionality correctly. Do not use type: ["string", "null"] (or x-nullable: true) to express that a field may be omitted from a response/request — that describes a literal null value, not absence. Omittable fields should simply be left out of the schema’s required list; only use nullable types when the API can genuinely return/accept an explicit null.

  3. 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>