📖 3 min read (~ 600 words).

Keyword reference

Keywords are the keyword: value lines that decorate an annotation block. They come in two flavours: inline (one line, keyword: value, the value classified by a value shape) and body (a header line plus indented continuation lines — a flat token list, a YAML map, or a per-line sub-language). Three things matter about any keyword: the class it belongs to, the annotation contexts that accept it, and its value shape.

This section groups the surface by class — pick the page that matches what you’re decorating. For the formal productions see grammar.md; for the value-shape and context-token reference tables see the Appendix.

Keyword classes

ClassCoversKeywords
Parameters & responsesrequest parameters and response headers (the reduced SimpleSchema surface)in, name, collectionFormat, examples, + the shared validations
Schema validations & decoratorsmodel schemas and struct fieldsmaximum/minimum/multipleOf, maxLength/minLength, maxItems/minItems, maxProperties/minProperties, pattern, patternProperties, additionalProperties, unique, default, example, enum, required, readOnly, discriminator, deprecated
Routes & operationsswagger:route / swagger:operation metadataschemes, consumes, produces, responses, parameters, tags
Securityauthentication requirements & scheme definitionssecurity, securityDefinitions
Spec metadataswagger:meta top-of-document fieldsversion, host, basePath, license, contact, tos, infoExtensions, externalDocs, extensions, tags
  • Keywords that decorate swagger:parameters fields and swagger:response headers — the reduced OAS 2.0 SimpleSchema surface, plus the parameter location and response-level examples.
  • Keywords that constrain and decorate a model schema or struct field — bounds, lengths, patterns, enums, defaults, and structural markers.
  • Keywords carried in a swagger:route or swagger:operation block — the operation’s transport metadata and its parameter and response bodies.
  • Keywords that wire authentication — the requirements that gate a spec, route, or operation, and the scheme catalogue declared once in meta.
  • Top-of-document keywords authored under swagger:meta — version, host, base path, license, contact, terms of service — plus the cross-cutting vendor-extension and external-docs keywords.
  • Reference tables — the value shapes the lexer classifies, and the meaning of each annotation-context token.

Context matrix

Which annotation family accepts a given keyword — the transpose of the annotation × keyword matrix. A ✅ means the keyword is legal on that annotation (on the annotation’s own block or on one of its fields); a blank means it is rejected there with a CodeContextInvalid diagnostic. The detailed entry for each keyword lives on its class page (linked above).

Keywordmetamodelparametersresponserouteoperation
maximum minimum multipleOf
maxLength minLength
maxItems minItems unique
pattern
collectionFormat
maxProperties minProperties
patternProperties additionalProperties
default example enum
required
readOnly discriminator
deprecated
in
name
examples
schemes consumes produces
security
securityDefinitions
responses parameters
tags
version host basePath license contact tos
infoExtensions
externalDocs
extensions

The parameters / response columns also cover the items sub-context (array elements): the array-element validations ride there too. model covers swagger:allOf member fields. See the Appendix for the precise meaning of each context token (param, header, schema, items, …).