rules

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rules contains the extra lint rules for the vacuum OpenAPI linter.

Every rule lives in its own file and is exposed as a constructor returning a Rule. A Rule is a vacuum custom function (it implements model.RuleFunction) that also knows the metadata a ruleset entry needs: the rule identifier, the severity, the JSONPath it is given and the how-to-fix message. The full catalogue is returned by All.

Rule identifiers are kebab-case and prefixed with "extra-" so that they never clash with the rules vacuum ships. The name of the custom function that backs a rule is identical to the rule identifier.

The ready-to-use ruleset (ruleset.yaml in the repository root) is generated from the catalogue with:

go generate ./...

Index

Constants

View Source
const (
	// TypeStyle marks a rule that enforces a convention.
	TypeStyle = "style"
	// TypeValidation marks a rule that enforces correctness.
	TypeValidation = "validation"
)

Rule types accepted by Spec.Type.

View Source
const CasingOption = "casing"

CasingOption is the name of the functionOption that every casing rule uses to select its naming convention. Its value is one of the names returned by casing.Names, or a list of them when a name may follow any of several.

View Source
const IDPrefix = "extra-"

IDPrefix is prepended to the name of every rule so that the identifiers never clash with the rules that vacuum ships.

View Source
const SeverityOff = "off"

SeverityOff is the severity that switches a rule off. vacuum's ruleset schema accepts it next to error, warn, info and hint.

Variables

This section is empty.

Functions

func Fold

func Fold(s string) string

Fold returns the lower-cased, trimmed form of s, the comparison form used for case-insensitive matching.

func ShortName

func ShortName(id string) string

ShortName returns the rule name without the IDPrefix.

Types

type Call

type Call struct {
	// Node is the node matched by the given JSONPath, with any document wrapper
	// removed.
	Node *yaml.Node
	// Root is the root mapping of the document being linted.
	Root *yaml.Node
	// contains filtered or unexported fields
}

Call is handed to a Check. It carries the matched node, the document root and typed accessors for the functionOptions of the rule.

func (*Call) Bool

func (c *Call) Bool(name string) bool

Bool returns a boolean option, or false when it is unset.

func (*Call) Has

func (c *Call) Has(name string) bool

Has reports whether the option was supplied by the user or has a default.

func (*Call) Int

func (c *Call) Int(name string) int

Int returns an integer option, or zero when it is unset. Numbers decoded from YAML may arrive as int, int64 or float64, and all of them are accepted.

func (*Call) String

func (c *Call) String(name string) string

String returns a string option, or the empty string when it is unset.

func (*Call) Strings

func (c *Call) Strings(name string) []string

Strings returns a list option. A single string is treated as a one element list, so both "a" and ["a", "b"] are accepted in a ruleset.

type Check

type Check func(call *Call) []Finding

Check inspects the node a rule was given and returns its violations.

func Concat

func Concat(checks ...Check) Check

Concat combines several checks into one that returns all of their findings.

func OnDocument

func OnDocument(check func(call *Call) []Finding) Check

OnDocument adapts a check over the whole document. It exists so that every rule reads the same way: a Spec's Check is always built by a combinator.

func PerOperation

func PerOperation(check func(call *Call, operation oas.Operation) []Finding) Check

PerOperation runs check for every operation of the document and returns all findings.

func PerParameter

func PerParameter(check func(call *Call, operation oas.Operation, parameter oas.Parameter) []Finding) Check

PerParameter runs check for every parameter of every operation, including the parameters inherited from the path item.

func PerPathItem

func PerPathItem(check func(call *Call, item oas.PathItem) []Finding) Check

PerPathItem runs check for every path item of the document and returns all findings.

func PerResponse

func PerResponse(check func(call *Call, operation oas.Operation, response oas.Response) []Finding) Check

PerResponse runs check for every response of every operation.

func PerSchema

func PerSchema(check func(call *Call, schema oas.Schema) []Finding) Check

PerSchema runs check for every schema of the document and returns all findings.

func WithCasing added in v1.2.0

func WithCasing(next func(call *Call, allowed casing.Set) []Finding) Check

WithCasing parses the shared casing option and hands the resulting set to next. An unknown value is reported as a single finding on the document that names the allowed values, and next is not run.

type Finding

type Finding struct {
	// Node is the YAML node the violation points at.
	Node *yaml.Node
	// Path is the JSONPath of the violation. An empty Path means the root.
	Path string
	// Message says what is wrong.
	Message string
}

Finding is one violation reported by a check.

func One

func One(finding Finding) []Finding

One returns a result holding a single finding. It is the value a per-item check returns when the item violates the rule.

func When

func When(condition bool, finding func() Finding) []Finding

When returns a single finding when condition holds, and no finding otherwise. The finding is built lazily so that it is only computed for violations.

type Option

type Option struct {
	// Name is the functionOptions key.
	Name string
	// Description explains what the option controls and its accepted values.
	Description string
	// Default is the value used when the option is not supplied. A nil Default
	// means the option has no default and the rule does nothing for it.
	Default any
}

Option describes one entry of the functionOptions a rule accepts.

type Rule

type Rule struct {
	// contains filtered or unexported fields
}

Rule is a vacuum custom function with the metadata of its ruleset entry.

func APIMaxOperations

func APIMaxOperations() Rule

APIMaxOperations returns the extra-api-max-operations rule.

What it checks

The total number of operations in the document, counted as the entries under paths that use one of the eight HTTP method keys (get, put, post, delete, options, head, patch and trace), must not exceed a limit. When the limit is exceeded a single finding is reported on the paths object.

A very large API surface is hard to document, review, version and consume; it is also a poor fit for tool-calling clients that must load every operation. A document that grows past the limit is a hint that it should be split into several smaller, focused APIs.

Where it comes from

The ai-api-lint rule api-max-operations, which flags documents with more than 40 operations.

Options

  • maxOperations (int, default 40): the largest number of operations that is still accepted. A value of zero or less disables the rule.

Bad

With maxOperations set to 1:

paths:
  /pets:
    get:
      responses: {}
    post:
      responses: {}

Good

paths:
  /pets:
    get:
      responses: {}

Known false positives

Operations that are only reachable through a $ref to an external path item are not counted, and path items reached through a local $ref are counted once per referencing path. The limit is global, so a large but cohesive API has to raise the option or disable the rule.

func APISymmetryGetVsWriteSchemas

func APISymmetryGetVsWriteSchemas() Rule

APISymmetryGetVsWriteSchemas returns the extra-api-symmetry-get-vs-write-schemas rule.

What it checks

For every resource-oriented path, a generic path that has a sibling made of the same path plus one trailing path parameter (/pets and /pets/{petId}), the canonical schema of the resource is the schema referenced by the JSON success response of the GET operation of the resource-specific sibling. The success response is the 200 response when present, otherwise the first 2xx response that has a JSON (application/json) schema; the first application/json media type is used. The canonical schema is found by the name of the #/components/schemas reference that the response schema is.

When components.schemas also defines schemas named after the canonical name plus Summary, Prototype or Patch, each of these variants must be a graph fragment of the canonical schema. A graph fragment has the structure of the canonical schema but may omit properties, at any nesting level. The variant is reported (at its place in components.schemas) when:

  • its schema type (array, object, boolean, string and its formats, integer and number and their formats, otherwise unknown) differs from the canonical type, unless the variant is checked as an allOf/oneOf/anyOf member;
  • it defines a property that does not exist on the canonical schema (exists means present with the same type), or that exists but whose own schema is not a graph fragment of the canonical property; properties marked writeOnly are exempt in Prototype variants;
  • it is an array whose items are not a graph fragment of the canonical items, or has additionalProperties or patternProperties that are not a graph fragment of the canonical ones (every variant pattern must exist on the canonical schema);
  • any allOf, oneOf or anyOf member of the variant is not a graph fragment of the canonical schema.

Looking things up in the canonical schema follows the IBM semantics: a property satisfies a constraint when the canonical schema itself, or any one of its allOf, oneOf or anyOf members, does. A canonical schema that is a reference to a schema named Xxx Reference (for instance WidgetReference) is replaced by the canonical schema named Xxx when that schema exists and does not contain a nested reference to the Reference schema.

Why

A summary, a prototype used to create a resource, and a patch used to update it describe the same resource as the canonical schema. When a variant invents properties or changes the type of one, the same concept is modelled twice and the models drift apart.

Where it comes from

IBM openapi-validator, ibm-api-symmetry (Variations of a resource schema should be graph fragments of the canonical schema).

Options

None.

Bad

paths:
  /pets:
    get: {}
  /pets/{id}:
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      properties:
        name: {type: string}
    PetPrototype:
      type: object
      properties:
        nickname: {type: string}

Good

components:
  schemas:
    PetPrototype:
      type: object
      properties:
        name: {type: string}

Known false positives and limitations

The original runs on a fully dereferenced document and tracks references through the Spectral graph; this port follows local $ref values on demand, with a recursion bound for circular schemas (a cycle is assumed to be a graph fragment). External references are not followed. Writing a reference to the canonical schema under a different name than components.schemas keys, or inlining it, makes the canonical schema impossible to find and the resource is skipped, as in the original.

func APIVersionInURL

func APIVersionInURL() Rule

APIVersionInURL returns the extra-api-version-in-url rule.

What it checks

The API must carry a version somewhere a client can see it. The document passes when at least one server URL, one path template, or one header parameter (request) or response header names a version. A version segment is a path segment such as v1, v2.1 or V3; a server variable whose name contains "version" also counts, as does a header whose name contains "version", such as Api-Version or X-API-Version. When none is found a single finding is reported on the document root.

Where it comes from

apilint, which requires a version in a server URL, a URI template matching v[0-9]+, or a version request or response header.

Options

None.

Bad

servers:
  - url: https://api.example.com
paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

servers:
  - url: https://api.example.com/v1

Known false positives

APIs versioned through media types (application/vnd.example.v2+json) or through query parameters other than a header are not recognised, and neither are versions that live only in a gateway outside the document.

func ActionVerbsInPath

func ActionVerbsInPath() Rule

ActionVerbsInPath returns the extra-action-verbs-in-path rule.

What it checks

No literal (non-parameter) segment of a path template may be an action verb such as get, create, update, delete, list, fetch, remove, add, set, find, search, make, do, run, execute, process, handle, post or put. The segment is lower-cased before it is compared with the verb list, and only whole segments are compared, so /settings or /lists are never flagged. One finding is reported per operation and offending segment.

Why

In a resource-oriented API the HTTP method is the verb and the path names the noun. Paths such as /createUser or /pets/get repeat the method, make the API harder to predict and push clients towards RPC-style naming.

Where it comes from

ai-api-lint (AI050, path segments should not contain verbs).

Options

  • verbs (list of strings, default: get, create, update, delete, fetch, remove, add, set, find, search, make, do, run, execute, process, handle, list, post, put): the segments that are treated as verbs. Values are compared case-insensitively.

Bad

paths:
  /pets/create:
    post:
      responses:
        "201":
          description: created

Good

paths:
  /pets:
    post:
      responses:
        "201":
          description: created

Known false positives

A segment that is a verb but also a legitimate noun, for example /set in a trading-card API or /run in a CI API, is flagged. Remove the entry from the verbs option to allow it. Action-style endpoints defined by design (for example /orders/{id}/cancel) are not flagged unless the verb is in the list.

func AdditionalPropertiesObjectOnly

func AdditionalPropertiesObjectOnly() Rule

AdditionalPropertiesObjectOnly returns the extra-additional-properties-object-only rule.

What it checks

A schema that declares a type other than object must not use the additionalProperties keyword. additionalProperties only constrains the extra members of an object, so on a string, number, integer, boolean or array schema it has no effect and almost always signals a misplaced keyword. A schema that declares no type at all is left alone, and so is a schema whose type list in OpenAPI 3.1 includes object.

Where it comes from

Specmatic's OpenAPI validation, which refuses additionalProperties outside object schemas.

Options

None.

Bad

components:
  schemas:
    Name:
      type: string
      additionalProperties: false

Good

components:
  schemas:
    Name:
      type: object
      additionalProperties:
        type: string

Known false positives

A schema that omits type but is clearly an object is not examined, so the rule can miss misplaced keywords there. A schema that combines type with composition keywords is judged only by its own type.

func AdminSecurityDiffers

func AdminSecurityDiffers() Rule

AdminSecurityDiffers returns the extra-admin-security-differs rule.

What it checks

An operation-level security requirement on an administrative path must not be identical to a security requirement used by any non-administrative operation. A path is administrative when its route contains the configured admin URL fragment. Two requirements are identical when they name the same security schemes with the same scopes, regardless of order. Operations without an operation-level security list are ignored.

Why

When administrators and ordinary users authenticate with the same scheme and scopes, any ordinary credential can reach the administrative surface, which makes privilege escalation a matter of a path change. Admin endpoints should require a distinct scheme or a distinct, dedicated scope.

Where it comes from

The Spectral OWASP ruleset (the differentSecuritySchemes function behind the owasp:api5:2023-admin-security-unique rule).

Options

  • adminUrl (string, default "/admin"): a route containing this text is treated as administrative.

Bad

paths:
  /users:
    get:
      security:
        - oauth: [read]
  /admin/users:
    get:
      security:
        - oauth: [read]

Good

paths:
  /users:
    get:
      security:
        - oauth: [read]
  /admin/users:
    get:
      security:
        - oauth: [admin]

Known false positives and limitations

Only operation-level security is compared; a global security list inherited by an operation is not considered. Matching the admin URL is a plain substring test, so a route such as /administrators is also administrative.

func All

func All() []Rule

All returns every rule of the catalogue ordered by identifier.

func AllofSchemaTypeIntersection

func AllofSchemaTypeIntersection() Rule

AllofSchemaTypeIntersection returns the extra-allof-schema-type-intersection rule.

What it checks

A schema that declares an explicit type and also lists allOf branches that declare their own types must keep a non-empty intersection of those types. allOf means "valid against every branch", so a schema of type string whose allOf branch is of type integer can never be satisfied. Only the schema and its immediate allOf branches are compared, and only explicit type keywords count; branches without a type are ignored. A $ref branch is resolved first. Type lists of OpenAPI 3.1 are supported, and integer is treated as a subset of number.

Why

An empty intersection makes the schema unsatisfiable, so no value can ever validate against it. It is almost always a copy and paste mistake, and generators produce a broken or empty model for it.

Where it comes from

The Speakeasy OpenAPI linter (allof-schema-type-intersection, also known as semantic-allof-type-conflict). vacuum ships a related allof-conflicts rule that compares properties; this one compares the type keyword.

Options

None.

Bad

components:
  schemas:
    Pet:
      type: object
      allOf:
        - type: string

Good

components:
  schemas:
    Pet:
      type: object
      allOf:
        - properties:
            name:
              type: string

Known false positives / limitations

Only the immediate branches are compared; nested allOf, oneOf and anyOf are not followed. Values of the type keyword that are not JSON Schema types are compared literally.

func AllowReservedQueryOnly

func AllowReservedQueryOnly() Rule

AllowReservedQueryOnly returns the extra-allow-reserved-query-only rule.

What it checks

The allowReserved keyword of a parameter object is only meaningful for query parameters. The rule flags allowReserved: true on path, header and cookie parameters and on header objects (response headers and components.headers).

Why

The specification defines allowReserved as "determines whether the parameter value SHOULD allow reserved characters ... to be included without percent-encoding. This property only applies to parameters with an in value of query." Setting it elsewhere is silently ignored by tooling, so it hides a mistake in the description.

Where it comes from

The KaiZen OpenAPI parser (allowReserved is set only on query parameters, also warning on headers).

Options

None.

Bad

paths:
  /pets/{id}:
    get:
      parameters:
        - name: id
          in: path
          required: true
          allowReserved: true
          schema:
            type: string

Good

paths:
  /pets:
    get:
      parameters:
        - name: filter
          in: query
          allowReserved: true
          schema:
            type: string

Known false positives / limitations

Only parameter and header objects are inspected. The allowReserved keyword of an encoding object (multipart and form bodies) is not checked. Parameters reached only through an external $ref are not followed.

func ArrayBoundsAndItemsConsistency

func ArrayBoundsAndItemsConsistency() Rule

ArrayBoundsAndItemsConsistency returns the extra-array-bounds-and-items-consistency rule.

What it checks

Every array schema (type array, in any schema reachable from the paths and the components) must define an items schema, should define numeric minItems and maxItems, and must not set minItems above maxItems. Attributes are also looked up inside allOf members of the schema, so a composed array is judged by the sum of its parts.

Why

An array without items accepts anything and generates untyped client code. An array without bounds invites unbounded payloads, which is both a robustness and a denial-of-service risk, and contradicting bounds make the schema impossible to satisfy.

Where it comes from

IBM openapi-validator (ibm-array-attributes).

Options

  • requireBounds (bool, default true): also require numeric minItems and maxItems. With false only items and the minItems/maxItems ordering are checked.

  • requireMinItems (bool, default true): when requireBounds is true, also require a numeric minItems. With false a missing minItems is not reported while maxItems and items are still checked, which suits arrays bounded only from above. The minItems/maxItems ordering check still runs when both are present.

Bad

components:
  schemas:
    Tags:
      type: array

Good

components:
  schemas:
    Tags:
      type: array
      minItems: 0
      maxItems: 100
      items:
        type: string

Known false positives and limitations

A schema reached only through a $ref is judged where it is defined. Arrays whose type is declared only in an anyOf or oneOf member are not recognised as arrays. The IBM rule's additional complaints about enum on arrays and about array keywords on non-array schemas are covered by other rules.

func ArrayParameterSerialization

func ArrayParameterSerialization() Rule

ArrayParameterSerialization returns the extra-array-parameter-serialization rule.

What it checks

Every parameter whose schema is an array must declare both style and explode. Parameters are read from operations, from path items and from components.parameters. The check can be limited to some parameter locations with the in option.

Why

The default serialization of an array depends on the parameter location and differs between tools and OpenAPI versions (form with explode true for query, simple for path and header). Spelling it out makes the wire format explicit, so clients, servers and documentation agree.

Where it comes from

Redocly CLI (array-parameter-serialization).

Options

  • in: list of parameter locations to check. Default: query, header, path, cookie.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: tags
          in: query
          schema:
            type: array
            items:
              type: string

Good

paths:
  /pets:
    get:
      parameters:
        - name: tags
          in: query
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string

Known false positives / limitations

Parameters described with content instead of schema carry no style and are ignored. A parameter shared through a $ref is reported once, where it is first used.

func ArrayRequiresItems

func ArrayRequiresItems() Rule

ArrayRequiresItems returns the extra-array-requires-items rule.

What it checks

Every schema that declares type: array (or, in OpenAPI 3.1, a type list that contains "array") must define an items keyword. In OpenAPI 3.1 a schema that defines prefixItems is accepted as well unless the option is switched off.

Why

OpenAPI 3.0 makes items mandatory for arrays. Without it, generators cannot pick an element type and fall back to untyped lists, and consumers cannot validate the elements.

Where it comes from

The scalar "array-items-required" rule and the Spectral "array-requires-items" rule. The two rows of the source list are merged.

Options

  • allowPrefixItems (bool, default true): treat prefixItems as a valid replacement for items.

Bad

components:
  schemas:
    Tags:
      type: array

Good

components:
  schemas:
    Tags:
      type: array
      items:
        type: string

Known false positives / limitations

A schema that is an array only through allOf composition (type: array in a referenced parent, items in the child) is judged per schema, so a child that repeats type: array without items is flagged even when the parent has them.

func AvoidInlineObjectSchemas

func AvoidInlineObjectSchemas() Rule

AvoidInlineObjectSchemas returns the extra-avoid-inline-object-schemas rule.

What it checks

Object schemas must be defined once under components/schemas and referenced with $ref instead of being written inline. A schema is reported when it is not itself a $ref, it does not live directly under components/schemas, and it is an object schema: it defines properties or it composes other schemas with allOf, anyOf or oneOf. The schema positions that are inspected are request and response bodies, parameters and headers, and every nested position (properties, items, additionalProperties and the composition keywords). Primitive schemas such as a string or an array of strings are never reported.

Named models give code generators a type name to use, keep the description of a structure in one place and make the document smaller. Anonymous inline objects force generators to invent names and make it impossible to reuse the structure.

Where it comes from

IBM openapi-validator, rule ibm-avoid-inline-schemas.

Options

  • allowReferenceUnions (bool, default false): do not report a oneOf, anyOf or allOf whose members are all $refs (or a plain null type). Such a union defines no object itself, so it is often acceptable inline.

Bad

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      properties:
        name:
          type: string

Known false positives

Every inline object is reported, including objects nested inside another inline object, so one inline structure can produce several findings. Schemas that are intentionally anonymous, such as a one-off error payload, have to be named or the rule suppressed for that location. An object schema without properties or composition (a free-form object) is not reported.

func BannedWordsInDocs

func BannedWordsInDocs() Rule

BannedWordsInDocs returns the extra-banned-words-in-docs rule.

What it checks

Every description, summary and title string in the document is searched for the configured words. Matching is case-insensitive and on word boundaries, so the word "simple" matches "Simple" and "a simple call" but not "simplest" or "simplex". One finding is reported for each banned word found in each string.

Why

Words such as "simply", "just", "obviously" or "easy" are subjective, patronise readers and age badly. Teams keep a short list of terms that must not appear in published documentation, for style or for legal reasons.

Where it comes from

openapilint (banned words in documentation fields).

Options

  • words (list of strings, no default): the banned words. Each entry is matched literally. When the list is empty the rule does nothing.

Bad

# words: [simply]
paths:
  /pets:
    get:
      summary: Simply list pets

Good

paths:
  /pets:
    get:
      summary: List pets

Known false positives

Example payloads that contain a key named description, summary or title are also scanned, so banned words inside example data are reported. A banned word that contains non-word characters, such as "c++", only matches where word boundaries exist around its first and last character.

func BooleanParameterPrefix

func BooleanParameterPrefix() Rule

BooleanParameterPrefix returns the extra-boolean-parameter-prefix rule.

What it checks

The name of a parameter whose schema has type boolean must start with one of the configured prefixes, followed by an upper-case letter, an underscore or a hyphen, or be exactly the prefix. This keeps flags readable as questions: isActive, has_children and is-visible read well, while active and enabled do not say what the flag answers. The schema of a parameter is followed through a local $ref, and parameters declared in components and path items are checked once.

Where it comes from

Redocly CLI's boolean-parameter-prefixes rule.

Options

  • prefixes: list of allowed prefixes. Default: is, has. An empty list disables the rule.

Bad

parameters:
  - name: active
    in: query
    schema:
      type: boolean

Good

parameters:
  - name: isActive
    in: query
    schema:
      type: boolean

Known false positives

Names that are established by an external protocol (for example a "dryRun" query flag) are flagged; add a suppression or extend the prefixes. Matching is case sensitive, so "IsActive" is rejected.

func CORSOriginHeader

func CORSOriginHeader() Rule

CORSOriginHeader returns the extra-cors-origin-header rule.

What it checks

Every response of every operation must define the Access-Control-Allow-Origin header in its headers map. A response without headers, or with headers that do not include it, is reported. Header names are compared case-insensitively.

Why

Browsers only let a page read a cross-origin response when the server returns Access-Control-Allow-Origin. Documenting it on every response makes the intended CORS policy explicit and reviewable, and lets clients and gateways know about it.

Where it comes from

The OWASP API security ruleset for Spectral (owasp:api8:2023-define-cors-origin).

Options

  • header: the header every response must define. Default: Access-Control-Allow-Origin.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: string

Known false positives / limitations

APIs that are never called from a browser do not need the header, and for them the rule is noise; disable it. Responses defined only under components.responses are checked where they are referenced from an operation.

func CollectionResponseHasNamedArray

func CollectionResponseHasNamedArray() Rule

CollectionResponseHasNamedArray returns the extra-collection-response-has-named-array rule.

What it checks

For every list operation, each JSON success (2xx) response schema must define an array property named after the last segment of the path. A GET is a list operation when its operationId starts with the configured prefix (default "list"), or when the last path segment is not a path parameter and a sibling path of the form {route}/{param} exists. Properties of allOf members count, and $ref schemas are resolved. Binary (file download) responses are skipped.

Why

Wrapping a collection in an object with a predictably named array lets the API grow pagination metadata without breaking clients, and gives generated SDKs a consistent way to reach the items: GET /things returns an object with a "things" array.

Where it comes from

IBM openapi-validator (ibm-collection-array-property).

Options

  • operationIdPrefix (string, default "list"): operationIds starting with this text mark a GET as a list operation. Set it to an empty string to rely on the path heuristic alone.

Bad

paths:
  /things:
    get:
      operationId: list_things
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items: {type: string}

Good

schema:
  type: object
  properties:
    things:
      type: array
      items: {type: string}

Known false positives and limitations

The path heuristic treats any GET whose path has a sibling item path as a list, so an unusual singleton route next to an item route is flagged. A top-level array response is flagged because it has no named property.

func ComponentNameMaxLength

func ComponentNameMaxLength() Rule

ComponentNameMaxLength returns the extra-component-name-max-length rule.

What it checks

The keys of components.schemas, requestBodies, responses, parameters, examples, headers and securitySchemes must not be longer than a maximum number of characters.

Why

Code generators turn component names into class, type and file names. Very long names produce unreadable identifiers and can exceed file name or identifier limits of the target language or file system.

Where it comes from

Rate My OpenAPI (apimatic-component-name-max-length).

Options

  • maxLength: the longest accepted key, counted in characters. Default: 50.

Bad

components:
  schemas:
    TheVeryLongNameOfASchemaThatKeepsGoingAndGoingAndGoingForever:
      type: object

Good

components:
  schemas:
    Pet:
      type: object

Known false positives / limitations

Components of other sections (links, callbacks, pathItems) are not checked. Names that contain multi-byte characters are counted by character, not byte.

func ComponentSchemaNameCase

func ComponentSchemaNameCase() Rule

ComponentSchemaNameCase returns the extra-component-schema-name-case rule.

What it checks

Every key of components.schemas must follow the configured case convention, PascalCase by default. The shared casing option selects another convention, for example kebab-case for an API whose schemas are named pet-owner, and the ignore option excludes generated names that follow no convention.

Why

Schema names become type names in generated clients. A consistent spelling produces idiomatic names in every target language and keeps $ref pointers predictable.

Where it comes from

The Oxide OpenAPI lint (component-schema-name-case) and the IBM API Handbook ruleset (schema-name-upper-camel-case). The two rows are merged.

Options

  • casing (string or list, default "PascalCase"): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A name is accepted when it follows any listed convention, an empty list disables the casing check and an unknown value is reported.
  • ignore (string or list of regular expressions, default none): schema names that match any expression (unanchored, Go RE2 syntax) are not checked. Generated error schemas such as auth-csrf_invalid, a kebab prefix followed by a snake_case code, are excluded with ignore: ["^auth-.*_"], or with "_" to skip every name that contains an underscore. An expression that does not compile is reported.

Bad

components:
  schemas:
    pet_store:
      type: object

Good

components:
  schemas:
    PetStore:
      type: object

With casing: kebab-case and ignore: ["^auth-.*_"], pet-store and auth-csrf_invalid are accepted and PetStore is reported.

Known false positives / limitations

PascalCase is checked loosely: an upper-case first letter followed by letters and digits, so acronym runs such as HTTPError and ID are accepted. The stricter IBM expression that rejects such names is not offered.

func CompositionBranchesSameType

func CompositionBranchesSameType() Rule

CompositionBranchesSameType returns the extra-composition-branches-same-type rule.

What it checks

For every schema that uses allOf, anyOf, oneOf or not, all the leaf schemas reachable through those keywords must declare the same type. Branches are followed through $ref and through nested compositions, so only the leaves (schemas without a composition keyword of their own) are compared. Leaves that declare no type are ignored. A type list such as [string, "null"] is compared as a whole, so it differs from plain string.

A composition that mixes, for example, an object and a string describes a value that no consumer can model with one static type, and most code generators fail or fall back to an untyped value.

Where it comes from

The Oxide OpenAPI lint, which requires every leaf of a oneOf, allOf, anyOf or not to have the same type.

Options

None.

Bad

components:
  schemas:
    Id:
      oneOf:
        - type: string
        - type: integer

Good

components:
  schemas:
    Id:
      oneOf:
        - type: string
          format: uuid
        - type: string
          format: ulid

Known false positives

A deliberate union of different primitive types is reported; this is the pattern the rule exists to discourage. Nullable unions written as oneOf [T, type null] are reported too. Compositions that are only resolved through an external $ref are not followed.

func ConsistentPropertyNameAndType

func ConsistentPropertyNameAndType() Rule

ConsistentPropertyNameAndType returns the extra-consistent-property-name-and-type rule.

What it checks

Properties that have the same name in different schemas must be declared with the same type. The first declaration of a name, in document order, fixes the expected type; every later property of that name with another type is reported. The type of a property is the sorted set of its declared types after local $ref resolution (so "integer" and ["integer", "null"] are different types). Properties without a type, and properties whose $ref cannot be resolved, are ignored.

Why

A field called "id" that is a string in one schema and an integer in another forces clients to special-case the field and usually points to an accidental modelling mistake.

Where it comes from

IBM's API Handbook ruleset (ibm-property-consistent-name-and-type). It is off by default there and is a warning here.

Options

  • ignore (list of strings, default empty): property names that are exempt.

Bad

components:
  schemas:
    Pet:
      type: object
      properties:
        id: {type: string}
    Owner:
      type: object
      properties:
        id: {type: integer}

Good

components:
  schemas:
    Pet:
      type: object
      properties:
        id: {type: string}
    Owner:
      type: object
      properties:
        id: {type: string}

Known false positives

Names that are deliberately overloaded, such as "value" or "data", are flagged; list them in the ignore option. A schema that is reachable twice is only inspected once.

func ContentMustHaveSchema

func ContentMustHaveSchema() Rule

ContentMustHaveSchema returns the extra-content-must-have-schema rule.

What it checks

Every entry of a content map must contain a schema. This applies to request bodies, responses, response headers and parameters that use content instead of schema, including the reusable ones declared under components. A media type with no schema tells tools nothing about the payload, so generated clients and validators fall back to untyped data. Objects that are $ref references are skipped because their target is checked where it is declared.

Where it comes from

IBM's openapi-validator (ibm-content-contains-schema).

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json: {}

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string

Known false positives

Media types that carry opaque bytes (for example application/octet-stream) are flagged even though a schema adds little; use type: string with format: binary to satisfy the rule.

func ContentTypeAllowList

func ContentTypeAllowList() Rule

ContentTypeAllowList returns the extra-content-type-allow-list rule.

What it checks

Every media type used in a request body or a response content map, whether inline or declared under components.requestBodies and components.responses, must be in the allowed list. Media type parameters (for example "; charset=utf-8") and letter case are ignored when comparing, and an allowed entry of the form "type/*" matches every subtype of that type.

Why

Restricting an API to a small set of media types keeps client generators, gateways and documentation consistent and prevents a stray text/plain or application/xml body from slipping in unnoticed.

Where it comes from

apilint (content-type), including its second half: for every media type that is allowed, the example bodies are parsed according to the media type and then validated against the schema of the media type.

Example bodies

For each media type in the allowed list, the media type object's example and the value of each entry of examples (a $ref to components.examples is followed) is checked. For application/json (and +json types) a string example is parsed as JSON text, and for application/yaml, application/x-yaml and text/yaml (and +yaml types) as YAML text; a parse failure is reported as "JSON body does not parse correctly!" or "YAML body does not parse correctly!". A string example whose schema declares type string is taken as the string value itself and not parsed. An example written as structured YAML is already parsed. Other media types (XML, text) are not parsed, as in apilint. The parsed body is then validated against the media type schema (a $ref is followed) and the first failure is reported as "example body does not match schema!" with the path in the body. The validator covers type (including nullable and OpenAPI 3.1 type lists), enum, const, required, properties, additionalProperties, items, minItems, maxItems, uniqueItems, minProperties, maxProperties, minLength, maxLength, pattern, minimum, maximum, exclusiveMinimum, exclusiveMaximum (boolean and numeric forms), multipleOf, allOf, anyOf, oneOf, not and the formats date-time, date, time, email, uuid, uri, hostname, ipv4 and ipv6. Unknown formats and keywords are ignored.

Options

  • mimetypes (list of strings, default ["application/json"]): the allowed media types. A single string is accepted as a one element list.
  • validateExamples (boolean, default true): parse and validate example bodies of the allowed media types as described above.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            text/plain:
              schema: {type: string}

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema: {type: string}

Known false positives and limitations

File upload and download endpoints legitimately use media types such as application/octet-stream or multipart/form-data; add them to the list. Wildcard media types in the document ("*/*") are compared literally. The example validator is a purpose built subset of JSON Schema; schemas that rely on unevaluated keywords, dependent schemas, conditionals or remote references are not fully checked.

func DateNamedPropertyMustUseDateFormat

func DateNamedPropertyMustUseDateFormat() Rule

DateNamedPropertyMustUseDateFormat returns the extra-date-named-property-must-use-date-format rule.

What it checks

A port of IBM's ibm-use-date-based-format. Schemas that model dates must be strings with format date or date-time; whether a schema models a date is decided heuristically, in two ways, for every schema reached from a request body, a response body, a parameter or header (and every nested property, items, additionalProperties and patternProperties schema below them) as well as every components.schemas entry. A schema that is already a date or date-time schema (composition-aware: its own type string and format, any allOf member, or every oneOf and anyOf member) is accepted.

  1. By name. A schema that is the value of a property (properties.<name>) whose name is date-based and that is a string or integer schema is reported with "According to its name, this property should use type "string" and format "date" or "date-time"". Date-based names are: created, updated, modified, expired, expires; names ending in _at or _on; names starting with date_ or time_; names containing _date_ or _time_; names ending in _date; the names start_time, end_time, create_time, created_time, modify_time, modified_time and update_time; and names containing timestamp. Names ending in depends_on are exempt.
  2. By example. A string schema whose example value looks like a date or a time is reported with "According to its example value, this schema should use type "string" and format "date" or "date-time"". The example is looked up the way IBM does: the examples of the schema itself and of its allOf, oneOf and anyOf members (example, or the examples array); the matching value inside the example of an enclosing schema (following properties, array items and dictionary values); and, for the schema of a request body, response body or parameter, the example or examples of the media type or parameter object that holds it. The first example found is used; null examples are ignored. A value looks like a date when, for a string, it contains no lowercase letters other than month and day names and matches a month name, YYYY-MM-DD, DD-MM-YYYY, MM-DD-YYYY (with ".", "/" or "-") or hh:mm:ss.

Why

A logical date typed as a bare string or integer loses its meaning. Date formats let generators emit native date types and let validators reject malformed values.

Where it comes from

IBM's openapi-validator (ibm-use-date-based-format, severity warn; name and value heuristics from utils/date-based-utils.js).

Options

  • names (list of strings, default empty): additional exact property names that are treated as date-based (an extension of this port).

Bad

components:
  schemas:
    Resource:
      type: object
      properties:
        created_at:
          type: integer
        stamp:
          type: string
          example: "1990-12-31T23:59:60Z"

Good

components:
  schemas:
    Resource:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        stamp:
          type: string
          format: date-time

Known false positives and limitations

The name heuristic matches names such as start_date_range that are not dates. IBM validates only schemas that an operation uses; this rule also validates every components.schemas entry and does not follow a $ref below a property into the target's own nested schemas (the target is checked where it is defined, but a $ref property is judged by its name and by the target schema).

func DateTimePropertySuffix

func DateTimePropertySuffix() Rule

DateTimePropertySuffix returns the extra-date-time-property-suffix rule.

What it checks

Every property that is a string with format date, time or date-time must have a name that matches, in full, at least one of the configured patterns. The defaults are .+_at, (.+_)*time(stamp)?(_.+)?, (.+_)*date(_.+)* and (.+_)*day(_.+)*, so created_at, start_time, last_timestamp, birth_date and day_of_week are accepted, while created, createdAt and opens are reported. Matching is case-sensitive and the same list applies to the three formats. The property may be declared inline or through a $ref to a schema that declares type and format.

Consistent names (created_at, birth_date, start_time) let readers and generated clients distinguish timestamps, calendar dates and times of day without opening the schema.

Where it comes from

Zally rule 235, "Name date/time properties using the common conventions" (DateTimePropertiesSuffixRule), whose DateTimePropertiesSuffixRule.patterns setting holds the default patterns and whose severity is SHOULD.

Options

  • patterns (list of strings, default the four patterns above): regular expressions, each of which must match the whole property name. An empty list disables the rule, and a pattern that is not a valid regular expression is ignored.

Bad

components:
  schemas:
    Pet:
      type: object
      properties:
        created:
          type: string
          format: date-time

Good

components:
  schemas:
    Pet:
      type: object
      properties:
        created_at:
          type: string
          format: date-time

Known false positives / limitations

Names that are clear without a suffix (for example "timestamp" alone is accepted, but "modified" is not) are reported unless the patterns are widened. Zally only looks at leaf properties; this rule looks at every string property found by the schema walker, which is the same set in practice. Patterns use the Go regexp syntax (RE2).

func DeepobjectExampleKeys

func DeepobjectExampleKeys() Rule

DeepobjectExampleKeys returns the extra-deepobject-example-keys rule.

What it checks

For every query parameter with style deepObject whose schema is an object with declared properties, the keys of the parameter example (example, and the value of every entry of examples) must be properties of the schema. The check descends into nested objects: a nested example object is compared with the properties of the matching nested schema. Properties are collected through local $ref and allOf. A schema that allows additionalProperties, or that declares no properties, accepts any key.

Why

deepObject parameters are serialised as filter[status]=open&filter[page]=2. An example whose key is misspelt or no longer part of the schema produces request samples and mock servers that the real API rejects.

Where it comes from

Specmatic (deepObject example keys must match the schema).

Options

None.

Bad

parameters:
  - name: filter
    in: query
    style: deepObject
    schema:
      type: object
      properties:
        status: {type: string}
    example:
      state: open

Good

parameters:
  - name: filter
    in: query
    style: deepObject
    schema:
      type: object
      properties:
        status: {type: string}
    example:
      status: open

Known false positives

Properties contributed by oneOf or anyOf branches are not collected, so an example that uses a key declared only inside such a branch is flagged.

func DefaultEqualsExampleRedundant

func DefaultEqualsExampleRedundant() Rule

DefaultEqualsExampleRedundant returns the extra-default-equals-example-redundant rule.

What it checks

A schema that declares a default must not carry an example with the same value. The default is already rendered in documentation, so the repeated example adds noise and hides the fact that no distinct sample was written. Both the OpenAPI example keyword and each entry of an examples list are compared with the default using structural equality: scalars by value and type tag, sequences element by element and mappings key by key regardless of key order.

Where it comes from

Speccy's lint rules, which reject an example that equals the default.

Options

None.

Bad

components:
  schemas:
    Limit:
      type: integer
      default: 20
      example: 20

Good

components:
  schemas:
    Limit:
      type: integer
      default: 20
      example: 50

Known false positives

The numbers 1 and 1.0 are different spellings and are treated as different values. An example that deliberately demonstrates the default is flagged.

func DescriptionUsageHintWording

func DescriptionUsageHintWording() Rule

DescriptionUsageHintWording returns the extra-description-usage-hint-wording rule.

What it checks

An operation description (the summary is not considered) that is at least minLength characters long must contain at least one usage hint word, such as "returns", "allows" or "use". The comparison is a case-insensitive substring test. Operations without a description, or with one shorter than minLength, are not checked here; their absence is a different rule's concern.

Why

Descriptions are what people and language-model agents read to decide when to call an operation. A description that never says what the operation returns, allows or is used for makes that decision harder.

Where it comes from

ai-api-lint (AI013, description lacks usage hint words).

Options

  • hintWords (list of strings, default: use, call, returns, when, used to, allows, enables, provides, retrieves, creates, updates, deletes): the accepted hint words. An empty list disables the rule.
  • minLength (integer, default 30): descriptions shorter than this are skipped.

Bad

paths:
  /pets:
    get:
      description: The collection of every pet in the store.

Good

paths:
  /pets:
    get:
      description: Returns the collection of every pet in the store.

Known false positives and limitations

Matching is by substring, so "use" is found inside words such as "because" and "house". Descriptions in languages other than English will not contain the default words; configure hintWords for them.

func DiscourageHTTP422

func DiscourageHTTP422() Rule

DiscourageHTTP422 returns the extra-discourage-http-422 rule.

What it checks

An operation must not define a 422 (Unprocessable Content) response. Use 400 (Bad Request) for invalid request payloads instead.

Why

422 comes from WebDAV and is not part of the commonly understood set of status codes. Using 400 for every client side validation failure keeps error handling in clients simple and consistent.

Where it comes from

The Baloise Spectral ruleset (must-use-additional-standard-http-status-codes, the 422 warning). IBM's response-status-code-semantics rule contains the same check; it is also part of extra-response-status-code-semantics.

Options

None.

Bad

paths:
  /pets:
    post:
      responses:
        "422":
          description: invalid

Good

paths:
  /pets:
    post:
      responses:
        "400":
          description: invalid

Known false positives / limitations

Teams that deliberately separate syntax errors (400) from semantic validation errors (422) will see every such response reported; disable the rule for them.

func DiscriminatorPropertyExists

func DiscriminatorPropertyExists() Rule

DiscriminatorPropertyExists returns the extra-discriminator-property-exists rule.

What it checks

When a schema declares a discriminator, the property named by discriminator.propertyName must be defined by that schema. The property is found in the schema's own properties, in any allOf member, or in every member of a oneOf or anyOf list (so that each alternative carries it). Members are followed through local $ref.

Why

The discriminator tells clients which property selects the concrete type. If the property does not exist, clients cannot read it and the polymorphic mapping is unusable.

Where it comes from

The IBM API Handbook ruleset (discriminator-property-exists).

Options

None.

Bad

components:
  schemas:
    Pet:
      type: object
      discriminator:
        propertyName: kind
      properties:
        name:
          type: string

Good

components:
  schemas:
    Pet:
      type: object
      discriminator:
        propertyName: kind
      properties:
        kind:
          type: string

Known false positives / limitations

A discriminator on a base schema whose property is only declared in the subtypes that extend it through allOf is flagged, because the base schema is judged on its own. External $ref targets are not followed.

func DiscriminatorPropertyRequired

func DiscriminatorPropertyRequired() Rule

DiscriminatorPropertyRequired returns the extra-discriminator-property-required rule.

What it checks

When a schema declares a discriminator, the property named by the discriminator must be listed in the required array of that schema. The required list of any allOf member of the schema is accepted as well, because a base type is often composed that way. A discriminator given as a plain string (Swagger 2.0 style) is handled in the same way.

The OpenAPI specification states that the discriminator property must be required. Without it a payload may omit the property and no consumer can decide which subtype applies.

Where it comes from

KaiZen OpenAPI Parser, which validates that the discriminator property is part of the schema's required list.

Options

None.

Bad

components:
  schemas:
    Pet:
      type: object
      discriminator:
        propertyName: kind
      properties:
        kind:
          type: string

Good

components:
  schemas:
    Pet:
      type: object
      required: [kind]
      discriminator:
        propertyName: kind
      properties:
        kind:
          type: string

Known false positives

A schema that only uses oneOf or anyOf with a discriminator and defines the property in its members, not in itself, is reported. The required list of a member reached through $ref inside allOf is resolved, but required lists behind external references are not seen.

func DocumentHasOperations

func DocumentHasOperations() Rule

DocumentHasOperations returns the extra-document-has-operations rule.

What it checks

The document must contain at least one operation: a method object (get, put, post, delete, options, head, patch or trace) below an entry of paths, or below an entry of webhooks in OpenAPI 3.1. The finding is reported on the paths object, or on the document root when paths is missing.

Why

A document without operations describes nothing a client can call. It is usually the result of a broken merge, a wrong file being linted or a generator that failed silently, and every other rule passes on it vacuously.

Where it comes from

oas-kit (the walker counts operations and fails when there are none).

Options

None.

Bad

openapi: 3.0.3
info: {title: Empty, version: "1"}
paths: {}

Good

openapi: 3.0.3
info: {title: Pets, version: "1"}
paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Known false positives

Documents that only publish components (shared schema libraries) have no operations by design. Disable the rule for such files.

func EmptyRequiredOrEnum

func EmptyRequiredOrEnum() Rule

EmptyRequiredOrEnum returns the extra-empty-required-or-enum rule.

What it checks

In every schema the required and enum lists, when present as lists, must contain at least one entry and must not contain duplicates. An empty enum can never be satisfied, an empty required list is invalid in OpenAPI 3.0 and pointless in 3.1, and duplicated entries are always a copy and paste slip. The boolean required flag used by parameters and request bodies is not a list and is not examined.

Where it comes from

KaiZen OpenApi Parser, whose schema validation reports empty and duplicated required and enum lists.

Options

None.

Bad

components:
  schemas:
    Pet:
      type: object
      required: []
      properties:
        kind:
          type: string
          enum: [cat, cat]

Good

components:
  schemas:
    Pet:
      type: object
      required: [kind]
      properties:
        kind:
          type: string
          enum: [cat, dog]

Known false positives

None known. A property literally named required or enum is a mapping inside properties and is not mistaken for the keyword.

func EncodingKeysMatchProperties

func EncodingKeysMatchProperties() Rule

EncodingKeysMatchProperties returns the extra-encoding-keys-match-properties rule.

What it checks

Each key of a media type object's encoding map must name a property of the media type's schema. The schema is resolved if it is a $ref, and properties declared in allOf members are included. When the schema is missing, or uses anyOf or oneOf (so the property set cannot be known statically), the media type is not checked.

Why

The encoding map describes how individual properties of a multipart or form-urlencoded body are serialised. A key that matches no property is a typo or a leftover from a renamed property, and is silently ignored by tooling, so the intended encoding never applies.

Where it comes from

KaiZen OpenAPI Parser (media type encoding validation).

Options

None.

Bad

requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          avatar: {type: string, format: binary}
      encoding:
        avatr:
          contentType: image/png

Good

encoding:
  avatar:
    contentType: image/png

Known false positives and limitations

Schemas that accept arbitrary properties through additionalProperties or patternProperties are still checked against their declared properties only. Only inline media types of operations and of components.requestBodies and components.responses are visited.

func EnumValueCase

func EnumValueCase() Rule

EnumValueCase returns the extra-enum-value-case rule.

What it checks

Every string value of an enum must follow one of the configured case conventions, snake_case or SCREAMING_SNAKE_CASE by default. Null and non-string values are ignored. A value is snake_case when it consists of lower-case letters and digits separated by single underscores, and SCREAMING_SNAKE_CASE when it consists of upper-case letters and digits separated by single underscores. Mixed case, hyphens, spaces and leading, trailing or doubled underscores are reported by those defaults.

Why

Enum values become constants and variants in generated clients. A uniform casing maps cleanly onto the naming rules of every target language, while values such as "in-progress" or "InProgress" need per language conversion tables.

Where it comes from

The Oxide OpenAPI lint (enum-value-case), which accepts snake_case and SCREAMING_SNAKE_CASE as produced by the heck crate.

Options

  • casing (string or list, default [snake_case, SCREAMING_SNAKE_CASE]): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A value is accepted when it follows any listed convention, an empty list disables the rule and an unknown value is reported.

Bad

components:
  schemas:
    Status:
      type: string
      enum: [in-progress, Done]

Good

components:
  schemas:
    Status:
      type: string
      enum: [in_progress, done]

Known false positives / limitations

Enums whose values are fixed by an external standard (media types, country codes, HTTP methods) are reported even though they cannot be renamed. Suppress the rule for those schemas.

func ErrorContainerSchemaShape

func ErrorContainerSchemaShape() Rule

ErrorContainerSchemaShape returns the extra-error-container-schema-shape rule.

What it checks

A port of IBM's ibm-error-response-schemas, which holds error responses to the "Error container model" of the IBM API Handbook. Every schema of every media type (not only JSON) of a response whose status code is a number from 400 to 599 is examined ($ref chains are followed; ranges such as 4XX and default are not selected, as in the original). Nothing is merged: properties must be declared directly on the schema.

The container:

  • must be an object with properties;
  • must have a trace property that is a string schema;
  • may have a status_code property, which must be an integer schema;
  • must have an errors property that is an array schema whose items are an object with properties (the error model).

The error model:

  • must have a code property that is a string schema with an enum that is an array of the valid error codes;
  • must have a message property that is a string schema;
  • must have a more_info property that is a string schema;
  • may have a target property, which must be an object with properties (the error target model) that has a type property, a string schema whose enum holds exactly field, header and parameter in any order, and a name property that is a string schema.

A schema counts as a string (array, integer) schema through composition like in IBM's utilities: its own type, any allOf member, or every oneOf and anyOf member; a schema with items counts as an array.

Findings carry the original messages ("Error container model must be an object with properties", "Error model must contain property 'code' of type string", ...) and the original locations: the properties object when a property is missing, the property when it is wrong, the enum for an invalid enum. When the schema is a $ref the location is inside the referenced component.

Why

A uniform error body lets clients parse every failure of the service with one code path and lets documentation describe the possible error codes.

Where it comes from

IBM's openapi-validator (ibm-error-response-schemas, severity warn).

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "404":
          description: not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string

Good

paths:
  /pets:
    get:
      responses:
        "404":
          description: not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  trace:
                    type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          enum: [not_found]
                        message:
                          type: string
                        more_info:
                          type: string

Known false positives and limitations

This is a strict, opinionated shape, the only one the original accepts. Services that use RFC 9457 problem details or any other error format are flagged for every error response; do not enable the rule for them. Schemas composed with allOf are not merged for the object and property checks.

func ErrorResponseContentType

func ErrorResponseContentType() Rule

ErrorResponseContentType returns the extra-error-response-content-type rule.

What it checks

An error response (a response whose status code starts with 4 or 5, which includes ranges such as 4XX and 5XX) that declares a content object must offer an application/json entry. Media type parameters such as "; charset=utf-8" are ignored. Responses without any content, for example a bodiless 404, are not reported. Responses defined through a local $ref are resolved.

A single, predictable format for error payloads lets clients parse every failure the same way, whatever the endpoint returns on success.

Where it comes from

IBM openapi-validator, rule ibm-error-content-type-is-json.

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "404":
          description: not found
          content:
            text/plain:
              schema:
                type: string

Good

paths:
  /pets:
    get:
      responses:
        "404":
          description: not found
          content:
            application/json:
              schema:
                type: object

Known false positives

Problem Details responses served as application/problem+json are reported because only the exact application/json media type is accepted. Add an application/json entry or suppress the rule for such responses.

func ErrorResponseHasBody

func ErrorResponseHasBody() Rule

ErrorResponseHasBody returns the extra-error-response-has-body rule.

What it checks

Every 4xx response of every operation, including range keys such as 4XX, must declare a response body: a content map with at least one media type that has a schema. $ref responses are resolved. The finding is reported on the response.

Why

Clients need a machine-readable explanation of what went wrong. A 400 or 404 with only a description forces them to parse free text, and generated clients cannot type the error.

Where it comes from

apilint (error responses declare a body).

Options

  • requireSchema (boolean, default true): when false, a media type without a schema is accepted as long as content is not empty.

Bad

responses:
  "404":
    description: Not found

Good

responses:
  "404":
    description: Not found
    content:
      application/problem+json:
        schema:
          $ref: "#/components/schemas/Problem"

Known false positives

404 responses to HEAD requests, and 4xx responses that intentionally return no content, are flagged. A default response is not inspected.

func EtagWithConditionalHeaders

func EtagWithConditionalHeaders() Rule

EtagWithConditionalHeaders returns the extra-etag-with-conditional-headers rule.

What it checks

When any operation of a path item accepts an If-Match or If-None-Match header parameter (declared on the operation or on the path item, matched case-insensitively), every 2xx response of the GET operation of that same path item must declare an ETag response header. Clients can only send a conditional request when the resource hands out a validator to compare. A path item with conditional headers but no GET operation is not reported.

Where it comes from

IBM's API Handbook and openapi-validator guidance on conditional requests.

Options

None.

Bad

paths:
  /pets/{id}:
    get:
      responses:
        "200":
          description: ok
    put:
      parameters:
        - name: If-Match
          in: header
          schema:
            type: string

Good

paths:
  /pets/{id}:
    get:
      responses:
        "200":
          description: ok
          headers:
            ETag:
              schema:
                type: string

Known false positives

A 2xx GET response that cannot carry a validator (for example 204 returned for an empty collection) is flagged. Responses reached through $ref are reported at the operation, not at the component.

func ExampleBodyKeyCase

func ExampleBodyKeyCase() Rule

ExampleBodyKeyCase returns the extra-example-body-key-case rule.

What it checks

Property names inside example bodies must follow the configured case style. The examples checked are the example and examples[*].value of every JSON media type in request bodies and responses, inline or under components. Nested objects and arrays are walked, and every key of an object whose schema declares properties must follow the configured convention. The schema of the media type is followed alongside the example, through $ref, items, properties, additionalProperties and the allOf, oneOf and anyOf members.

Why

Examples are copied into client code, tests and documentation. An example that spells a property differently from the schema, or from the rest of the API, teaches the wrong convention and hides inconsistencies that schema-only naming rules cannot see.

Where it comes from

apilint (body-capitalization).

Options

  • casing (string or list, default "snake_case"): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A key is accepted when it follows any listed convention, an empty list disables the rule and an unknown value is reported.
  • ignoreKeys (string or list, default none): exact keys or glob patterns (path.Match syntax, for example givenName or x-*) that are never reported. A malformed pattern is reported.

Bad

responses:
  "200":
    description: ok
    content:
      application/json:
        example:
          firstName: Ada

Good

example:
  first_name: Ada

Known false positives and limitations

Keys of free-form maps (additionalProperties without properties), of objects with no schema, and of embedded documents are data rather than property names and are not checked. Names defined outside the API, such as OIDC claims like givenName, are excluded with ignoreKeys. Examples given as a string holding JSON, and $ref examples, are not inspected.

func ExampleValueXorExternal

func ExampleValueXorExternal() Rule

ExampleValueXorExternal returns the extra-example-value-xor-external rule.

What it checks

Every Example Object must define exactly one of value and externalValue. Example Objects are the entries of components.examples and of the examples maps of media types, parameters and headers, wherever they appear in the document. An example that defines both is reported, and so is one that defines neither. The OpenAPI 3.2 keywords dataValue and serializedValue count as inline values, like value.

Why

The specification states that value and externalValue are mutually exclusive. When both are present tools disagree about which one wins, and an example with neither carries no sample at all.

Where it comes from

Spectral (oas3-examples-value-or-externalValue), Scalar, speccy and the OpenAPI Specification linter of oas-kit (example-value-or-externalValue), KaiZen (example-single-value) and Redocly (no-example-value-and-externalValue). The tools differ in whether an example with neither keyword is an error, which is why both directions are options.

Options

  • forbidBoth: report examples that define both value and externalValue. Default: true.
  • requireOne: report examples that define neither. Default: true.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              examples:
                both:
                  value: {name: Rex}
                  externalValue: https://example.org/rex.json

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              examples:
                inline:
                  value: {name: Rex}

Known false positives / limitations

Examples that use only a $ref are resolved before they are checked; an example whose reference cannot be resolved is skipped. Examples nested in vendor extensions are not visited.

func ExplodedObjectQueryRequiredProperty

func ExplodedObjectQueryRequiredProperty() Rule

ExplodedObjectQueryRequiredProperty returns the extra-exploded-object-query-required-property rule.

What it checks

A required query parameter whose schema is an object and that is serialised with style form and explode true (both are the defaults for query parameters) must have a schema that lists at least one required property. The check looks at the required list of the schema, of its $ref target and of its allOf members.

Why

An exploded object is serialised as its individual properties: color=red &size=L rather than a single key. If no property is required, a client may send an object with no properties at all, which produces an empty query string, so the parameter that was declared required is never actually present on the wire and the server cannot tell it was omitted.

Where it comes from

Specmatic (exploded object query parameter validation).

Options

None.

Bad

paths:
  /search:
    get:
      parameters:
        - name: filter
          in: query
          required: true
          schema:
            type: object
            properties:
              color:
                type: string

Good

paths:
  /search:
    get:
      parameters:
        - name: filter
          in: query
          required: true
          schema:
            type: object
            required: [color]
            properties:
              color:
                type: string

Known false positives / limitations

Required lists contributed through oneOf or anyOf are not considered, and parameters described with content instead of schema are skipped.

func ExtensibleEnumStringType

func ExtensibleEnumStringType() Rule

ExtensibleEnumStringType returns the extra-extensible-enum-string-type rule.

What it checks

Every schema or property that carries the x-extensible-enum extension must have type string. A schema without a type is reported too. In OpenAPI 3.1 a type list is accepted when it contains string and, optionally, null.

An extensible enum lists the values known today while allowing clients to receive new ones, which only makes sense for strings.

Where it comes from

Zally, the guideline that x-extensible-enum is only defined for string values.

Options

None.

Bad

components:
  schemas:
    Colour:
      type: integer
      x-extensible-enum: [1, 2]

Good

components:
  schemas:
    Colour:
      type: string
      x-extensible-enum: [red, green]

Known false positives

A schema that gets its type from an allOf member and only adds the extension itself is reported because the type is not declared on the same schema.

func FormatMatchesType

func FormatMatchesType() Rule

FormatMatchesType returns the extra-format-matches-type rule.

What it checks

Every schema that declares both a type and a standard format must use a type that the format applies to. The built-in table is: int32 and int64 apply to integer; float and double to number (integer is accepted too, as the specification allows it); byte, binary, date, date-time, password, email, idn-email, hostname, idn-hostname, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uuid, duration, time, regex, json-pointer and relative-json-pointer to string. Formats that are not in the table are ignored. In OpenAPI 3.1, where type may be a list, the format is accepted when any listed type matches.

Why

A format narrows a type. date-time on an integer or int32 on a string is meaningless, and code generators either ignore the format or fail on it.

Where it comes from

KaiZen OpenAPI Parser (format and type must agree).

Options

None.

Bad

type: string
format: int32

Good

type: integer
format: int32

Known false positives

Vendor formats that happen to reuse a standard name, for example a numeric "time" format expressed as an integer, are flagged.

func GlobalSecurityRequired

func GlobalSecurityRequired() Rule

GlobalSecurityRequired returns the extra-global-security-required rule.

What it checks

The document root must declare a security property that is a non-empty list of security requirement objects. Declaring security globally makes every operation secure by default; operations that are public then opt out with an explicit empty list. A missing security property, an empty list, a value that is not a list, or a list entry that is not an object is reported.

Where it comes from

rate-my-openapi, whose security checks require a root security array with at least one item.

Options

None.

Bad

paths: {}

Good

security:
  - apiKey: []
paths: {}

Known false positives

Documents in which every operation sets its own security are flagged even though no operation is unprotected. A root list holding only an empty requirement object ({}) is accepted because it is syntactically a valid non-empty list, although it means anonymous access.

func HeaderNameMaxLength

func HeaderNameMaxLength() Rule

HeaderNameMaxLength returns the extra-header-name-max-length rule.

What it checks

The names of response headers, in operation responses and in components.responses, must be at most maxLength characters long. Response definitions that are $refs are checked where they are declared.

Why

Very long header names inflate every response, run into proxy and server header limits, and are awkward to read in logs and generated code.

Where it comes from

rate-my-openapi (response header names at most 50 characters).

Options

  • maxLength (integer, default 50): the longest allowed header name, counted in characters.

Bad

responses:
  "200":
    description: ok
    headers:
      X-Some-Extremely-Long-Header-Name-That-Keeps-Going-And-Going:
        schema: {type: string}

Good

responses:
  "200":
    description: ok
    headers:
      X-Request-Id:
        schema: {type: string}

Known false positives and limitations

Headers declared as parameters with in: header, and reusable headers under components.headers, are not response headers on their own and are not checked. A maxLength of zero or less disables the rule.

func HoistRepeatedPathParameters

func HoistRepeatedPathParameters() Rule

HoistRepeatedPathParameters returns the extra-hoist-repeated-path-parameters rule.

What it checks

When the same path parameter is declared, identically, in the parameters of more than one operation of one path item, it should be declared once at the path item level instead. Two parameters are identical when their resolved objects are structurally equal, regardless of key order. Only parameters with in: path are considered, and parameters already declared at the path item level are not reported.

Why

A path parameter belongs to the URL and so to every operation of the path item. Repeating it in each operation invites the copies to drift apart and makes the description longer than needed.

Where it comes from

IBM openapi-validator (ibm-avoid-repeating-path-parameters).

Options

None.

Bad

paths:
  /pets/{id}:
    get:
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}
    delete:
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}

Good

paths:
  /pets/{id}:
    parameters:
      - {name: id, in: path, required: true, schema: {type: string}}
    get: {}
    delete: {}

Known false positives / limitations

Every repeated occurrence is reported, including the first one. A parameter that differs between operations, for example in its description, is not considered a repeat.

func IgnoredHeaderNames

func IgnoredHeaderNames() Rule

IgnoredHeaderNames returns the extra-ignored-header-names rule.

What it checks

The OpenAPI specification says that header parameters named Accept, Content-Type or Authorization are ignored, and that a response header named Content-Type is ignored. The rule flags every such declaration, because the definition has no effect. Names are compared case-insensitively.

Why

The content type of a request is described by the requestBody content keys, the accepted type by the response content keys, and credentials by security schemes. Declaring them as headers produces documentation that tools do not honour and misleads readers.

Where it comes from

The KaiZen OpenAPI parser (a header named Content-Type is declared and ignored).

Options

  • names (list of strings, default [Accept, Content-Type, Authorization]): the request header names that are reported.

Bad

paths:
  /pets:
    post:
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object

Known false positives / limitations

None known; the names are fixed by the specification, and the option can be narrowed to Content-Type only.

func IllogicalCompositionKeywords

func IllogicalCompositionKeywords() Rule

IllogicalCompositionKeywords returns the extra-illogical-composition-keywords rule.

What it checks

A faithful port of Redocly CLI's no-illogical-composition-keywords. For every schema in the document (components, parameters, headers, request and response bodies and everything nested in them):

  • allOf, anyOf and oneOf: a oneOf or anyOf with fewer than two members is reported unless the schema declares a discriminator; an allOf with no member, or with one member when the schema has no other keyword and the member does not resolve to a schema that declares a discriminator (a subtype declaration), is reported;
  • members that are the empty schema {} (they match any value);
  • members that are deep-equal to an earlier member of the same keyword (the finding is on the later member and names the first position);
  • anyOf and oneOf with a discriminator: every member must be a $ref (or declare $id), because a discriminator selects a schema by its component name and cannot select an inline member;
  • oneOf: the schema is nullable (nullable: true, or null in type) and a resolved member also accepts null;
  • oneOf: every pair of members that a single value can match at once. The comparison is deliberately narrow, exactly as in Redocly: it reads type, nullable, enum, const, properties, required and additionalProperties false, and gives up on a pair when either member uses any other constraint keyword (not, pattern, minimum, nested allOf and so on; x- keywords and annotations are ignored). It reports shared null, shared enum or const values, a discriminator property that is not required in both members (except on OpenAPI 3.2, where spec-discriminator-defaultMapping covers it), optional properties that would tell the members apart, shared properties without constraints that exclude each other, and shared types (integer against number overlaps when the number side allows an integer).

An ambiguous oneOf has no single answer: validators, code generators and documentation disagree on which branch was meant.

Where it comes from

Redocly CLI, rule no-illogical-composition-keywords (packages/core/src/rules/oas3/no-illogical-composition-keywords.ts).

Options

None.

Bad

components:
  schemas:
    PhotoUrl:
      type: [string, "null"]
    MenuItemPhoto:
      oneOf:
        - $ref: "#/components/schemas/PhotoUrl"
        - type: "null"

Good

components:
  schemas:
    PhotoUrl:
      type: string
    MenuItemPhoto:
      oneOf:
        - $ref: "#/components/schemas/PhotoUrl"
        - type: "null"

Known false positives and limitations

$ref targets are followed only when they are local to the document; a member that points to another file is not compared. Redocly's source tracking of external files has no equivalent here. Boolean schemas used as members are skipped. Duplicate detection compares the raw members, like the original, so two different $ref strings that resolve to equal schemas are reported by the overlap check instead.

func IntegerBoundsInFormatRange

func IntegerBoundsInFormatRange() Rule

IntegerBoundsInFormatRange returns the extra-integer-bounds-in-format-range rule.

What it checks

Every schema of type integer must declare a format of int32 or int64 and, by default, both minimum and maximum. When a minimum or maximum is present it must lie inside the range of the declared format: -2147483648 to 2147483647 for int32 and -9223372036854775808 to 9223372036854775807 for int64. Findings are reported on the schema for missing keywords and on the keyword for out-of-range values.

Why

Without a format, generators pick whatever integer width they like; without bounds, clients and servers disagree on valid input and fuzzers have no range to work with. A bound outside the format can never be satisfied.

Where it comes from

IBM's API Handbook ruleset (ibm-integer-attributes).

Options

  • requireFormat (boolean, default true): require format int32 or int64.
  • requireBounds (boolean, default true): require minimum and maximum.

Bad

type: integer
format: int32
minimum: 0
maximum: 5000000000

Good

type: integer
format: int32
minimum: 0
maximum: 100

Known false positives

Integer schemas that are intentionally unbounded, such as opaque counters, are flagged; disable requireBounds to allow them. Schemas that only use exclusiveMinimum or exclusiveMaximum are treated as missing bounds.

func LinkParameterExists

func LinkParameterExists() Rule

LinkParameterExists returns the extra-link-parameter-exists rule.

What it checks

A port of the link validation of the KaiZen OpenApi Parser (LinkValidator), run against every link in components.links, components.responses and the responses of every operation:

  • a link must name its target with exactly one of operationId and operationRef (neither, or both, is an error);
  • an operationId must identify an operation of the document;
  • a local operationRef (#/paths/~1pets~1{id}/get, percent-encoding is decoded) must point at an operation of the document;
  • every key of the link parameters map must name a parameter of the target operation, including parameters inherited from the path item. A key may be qualified with its location (path.id, query.limit) or be bare (id). A bare key that matches parameters in more than one location of the target (a query and a header parameter of the same name) is ambiguous and is reported, as KaiZen's "name appears more than once" warning does;
  • an operationRef that is not local (another file or URL) cannot be followed. KaiZen warns that operationRef is not supported; this rule reports it unless the option is switched off, and then checks nothing else for that link.

Links that are a $ref are checked where they are defined.

Where it comes from

KaiZen OpenApi Parser, val3/LinkValidator.java (messages NoOpIdNoOpRefInLink, OpIdAndOpRefInLink, OpIdNotFound, OpPathNotFound, BadLinkParam, AmbigLinkParam and OperationRefUnSupp).

Options

  • reportRemoteOperationRef: report links whose operationRef is not local, because their parameters cannot be verified. Default: true.

Bad

paths:
  /pets/{id}:
    get:
      operationId: getPet
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}
      responses:
        "200":
          description: ok
          links:
            self:
              operationId: getPet
              parameters:
                petId: $response.body#/id

Good

self:
  operationId: getPet
  parameters:
    id: $response.body#/id

Known false positives and limitations

Only local references are resolved, so links to operations in external files are not checked (see the option). Parameters that the target inherits from an unresolved external path item are not seen.

func LinkTargetExists

func LinkTargetExists() Rule

LinkTargetExists returns the extra-link-target-exists rule.

What it checks

Every Link object, in operation responses, in components.responses and in components.links, must point at an operation that exists in the document:

  • operationId must equal the operationId of some operation of the document.
  • A relative operationRef (a JSON pointer starting with "#/paths/") must resolve to an existing operation under that path. External operationRef values (URLs and files) are not resolved and are accepted.
  • A link must define exactly one of operationId and operationRef.

Why

A link whose target does not exist is dead documentation: generators drop it or fail, and consumers follow a relation that cannot be called. Typos in operationIds are the usual cause, often after a rename.

Where it comes from

Merges speakeasy's link-operation-id-resolves and KaiZen's link-target-exists (its LinkValidator, which also rejects links with both or neither of the two keys).

Options

  • operationRefMethods (list of strings, default empty): the HTTP methods a relative operationRef may target. KaiZen only accepts get; the default accepts any method, as the OpenAPI specification does.

Bad

paths:
  /users:
    post:
      operationId: createUser
      responses:
        "201":
          description: created
          links:
            fetch:
              operationId: getUsr

Good

fetch:
  operationId: getUser

Known false positives and limitations

Operations declared only in an external document, or under path item $refs that cannot be resolved locally, are not seen, so links to them are flagged when given by operationId. Link parameters and requestBody expressions are not validated.

func MajorVersionInPath

func MajorVersionInPath() Rule

MajorVersionInPath returns the extra-major-version-in-path rule.

What it checks

The API must carry its major version in the URL. Either a server URL has a path segment of the form v<n> (for example https://api.example.com/v1), or every path of the paths object starts with such a segment (for example /v1/pets). When the paths carry the version, all of them must use the same version, unless the consistent option is turned off.

Why

A version in the URL lets a breaking change ship next to the old version, and makes the version visible in logs, gateways and browser address bars.

Where it comes from

IBM openapi-validator (ibm-major-version-in-path).

Options

  • allowServerVersion: accept a version segment in a server URL in place of versioned paths. Default: true.
  • consistent: require every versioned path to use the same version. Default: true.

Bad

servers:
  - url: https://api.example.com
paths:
  /pets: {}

Good

servers:
  - url: https://api.example.com/v1
paths:
  /pets: {}

Known false positives / limitations

Only the lower-case form v<digits> is recognized; minor versions such as v1.2 and date based versions are not. APIs that version through a header or a media type are reported; disable the rule for them. Server URLs that consist only of a variable are not inspected.

func MediaTypeAllowList

func MediaTypeAllowList() Rule

MediaTypeAllowList returns the extra-media-type-allow-list rule.

What it checks

Every media type of a request body (operation request bodies and components.requestBodies) must appear in the configured allow-list. Entries are compared case-insensitively after removing media type parameters such as charset, and an entry of the form type/* allows every subtype of that type. With includeResponses the media types of responses are checked too.

Why

Restricting the media types keeps an API predictable and prevents accidental support for formats that the server does not parse or that clients cannot generate.

Where it comes from

Redocly CLI (request-mime-type, with the allowed list configured per rule).

Options

  • allowed (list of strings, default empty): the permitted media types. The rule does nothing when the list is empty.
  • includeResponses (bool, default false): also check response content.

Bad

With allowed: application/json:

paths:
  /pets:
    post:
      requestBody:
        content:
          application/xml:
            schema:
              type: object

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object

Known false positives / limitations

Wildcards in the document (such as */*) are compared literally, so they only pass when the allow-list contains them. A $ref request body is reported once, at the component it points to.

func MergePatchNoRequired

func MergePatchNoRequired() Rule

MergePatchNoRequired returns the extra-merge-patch-no-required rule.

What it checks

The request body of a PATCH operation that is sent as application/merge-patch+json must not use required, or a minProperties greater than zero, anywhere in its schema. The schema is inspected after following $ref, and the properties, items, additionalProperties, allOf, anyOf, oneOf and not keywords are descended into. Any non-empty required list is reported. When the required list lives in a referenced schema, the finding is reported on the schema of the request body that reaches it.

A JSON merge patch (RFC 7396) only carries the fields that change, so a required property would force clients to resend fields they do not want to modify.

Where it comes from

IBM openapi-validator, rule ibm-dont-require-merge-patch-properties.

Options

None.

Bad

paths:
  /pets/{id}:
    patch:
      requestBody:
        content:
          application/merge-patch+json:
            schema:
              type: object
              required: [name]
              properties:
                name:
                  type: string

Good

paths:
  /pets/{id}:
    patch:
      requestBody:
        content:
          application/merge-patch+json:
            schema:
              type: object
              properties:
                name:
                  type: string

Known false positives

A schema shared between a create request and a merge patch request has to be split, because the shared required list is reported for the patch. Only local references are followed.

func MultiplePathParams

func MultiplePathParams() Rule

MultiplePathParams returns the extra-multiple-path-params rule.

What it checks

A path template must not contain more than the allowed number of path parameters (one by default). The parameters are counted by the number of {name} expressions in the template, so /orgs/{org}/repos/{repo} has two. One finding is reported per offending path, on the path item.

Why

A path with several identifiers usually means that a nested resource is addressed through its parents even though its own identifier is globally unique. Such paths are long, couple resources to their parents and are hard to evolve; a root path such as /repos/{repo} is often enough.

Where it comes from

Zally (avoid multiple path parameters, suggesting a nested resource could be a root path).

Options

  • max (integer, default 1): the largest number of path parameters a path may contain.

Bad

paths:
  /orgs/{org}/repos/{repo}:
    get: {}

Good

paths:
  /repos/{repo}:
    get: {}

Known false positives

Resources whose identifiers are only unique within their parent, such as /orders/{order}/lines/{line}, legitimately need several parameters. Raise max for such APIs.

func New

func New(spec Spec) Rule

New builds a Rule from its specification.

func NoArrayOfArrays

func NoArrayOfArrays() Rule

NoArrayOfArrays returns the extra-no-array-of-arrays rule.

What it checks

An array schema must not use an array schema as its items. Nested arrays cannot be extended with further members, are awkward in most generated clients and make the payload shape hard to document; wrapping the inner array in an object gives it a name and room to grow. The items schema is followed through a local $ref before it is inspected.

Where it comes from

IBM's openapi-validator (ibm-no-array-of-arrays).

Options

None.

Bad

components:
  schemas:
    Matrix:
      type: array
      items:
        type: array
        items:
          type: number

Good

components:
  schemas:
    Matrix:
      type: array
      items:
        type: object
        properties:
          values:
            type: array
            items:
              type: number

Known false positives

Geometry formats such as GeoJSON coordinate lists are inherently arrays of arrays and are flagged; suppress the rule for those schemas.

func NoBinaryInJSONAPI

func NoBinaryInJSONAPI() Rule

NoBinaryInJSONAPI returns the extra-no-binary-in-json-api rule.

What it checks

A binary string schema (type string with format binary), or a schema whose direct items are such a schema, must not be used as:

  • the schema of an operation or path item parameter (parameters[n].schema), or of a parameter's application/json content;
  • the schema of an application/json request body;
  • the schema of an application/json response body.

This follows the IBM implementation exactly. A schema is binary when it, or any allOf member, is a binary string, or when every oneOf or anyOf member is one (IBM schemaHasConstraint). Only the top-level schema and its direct items are examined, as in the original. A media type counts as JSON only when it is application/json, optionally followed by parameters (for example a charset); application/vnd.api+json and other +json types are not JSON for this rule. $ref values are resolved for schemas, parameters, request bodies and responses, and the finding is reported where the schema is used. Reusable objects under components are only checked through the operations using them, as in IBM, which only visits usage locations.

Findings use the IBM messages: "Parameters should not contain binary values (type: string, format: binary)", "Request bodies with JSON content ..." and "Responses with JSON content ...".

Why

JSON cannot carry raw bytes. A binary schema in a JSON message or in a parameter cannot be serialised faithfully, and generators produce broken clients for it. Binary content belongs in an octet-stream or multipart body, or should be encoded as a base64 string with format byte.

Where it comes from

IBM openapi-validator (ibm-binary-schemas).

Options

None.

Bad

requestBody:
  content:
    application/json:
      schema:
        type: string
        format: binary

Good

requestBody:
  content:
    application/octet-stream:
      schema:
        type: string
        format: binary

Known false positives and limitations

A binary property nested in an object schema is not reported, matching the original. Only local $ref values are followed.

func NoBodyOnSafeMethods

func NoBodyOnSafeMethods() Rule

NoBodyOnSafeMethods returns the extra-no-body-on-safe-methods rule.

What it checks

Operations whose HTTP method is in a configurable list must not define a requestBody. The default list is delete, get, head and options.

Why

RFC 9110 gives a request body on GET, HEAD, DELETE and OPTIONS no defined semantics. Proxies, caches and client libraries may drop it or reject the request, and many HTTP clients cannot send one at all.

Where it comes from

IBM openapi-validator (ibm-no-operation-requestbody), which has the same configurable list of methods.

Options

  • httpMethods: the methods that must not have a request body, compared case-insensitively. Default: delete, get, head, options.

Bad

paths:
  /pets:
    get:
      requestBody:
        content:
          application/json:
            schema:
              type: object

Good

paths:
  /pets:
    get:
      parameters:
        - name: filter
          in: query
          schema:
            type: string

Known false positives / limitations

OpenAPI 3.1 allows request bodies on every method, and some APIs rely on a body for DELETE or GET; remove the method from httpMethods for them.

func NoCircularSchemaRefs

func NoCircularSchemaRefs() Rule

NoCircularSchemaRefs returns the extra-no-circular-schema-refs rule.

What it checks

A component schema must not reference itself, directly or through other component schemas, by following $ref through its sub-schemas: properties, allOf, anyOf, oneOf, items, prefixItems, additionalProperties and not. Every component that sits on such a cycle is reported once, with the chain that leads back to it.

Why

Circular schemas cannot be fully expanded. Tools that dereference or bundle the document, generate example payloads or validate recursively either fail or loop, and several code generators produce unusable types.

Where it comes from

The IBM API Handbook ruleset (ibm-no-circular-refs).

Options

  • ignoreProperties (bool, default false): do not follow object properties, which allows the common tree shape (a node with an optional child list) while still reporting cycles that go through composition keywords.

Bad

components:
  schemas:
    Node:
      type: object
      properties:
        parent:
          $ref: "#/components/schemas/Node"

Good

components:
  schemas:
    Node:
      type: object
      properties:
        parentId:
          type: string

Known false positives / limitations

Legitimate recursive data structures such as trees are reported unless ignoreProperties is set. Only local references to components.schemas are followed.

func NoConsecutivePathParameterSegments

func NoConsecutivePathParameterSegments() Rule

NoConsecutivePathParameterSegments returns the extra-no-consecutive-path-parameter-segments rule.

What it checks

A path template must not contain two adjacent segments that each hold a path parameter, such as /pets/{petId}/{ownerId}. A segment holds a parameter when it contains a brace pair. Each reported path is flagged once.

Two parameters in a row hide the resource that sits between them. Naming the collection (/pets/{petId}/owners/{ownerId}) makes the URL readable and keeps the hierarchy of resources explicit.

Where it comes from

IBM openapi-validator, rule ibm-no-consecutive-path-parameter-segments.

Options

None.

Bad

paths:
  /pets/{petId}/{ownerId}:
    get:
      responses: {}

Good

paths:
  /pets/{petId}/owners/{ownerId}:
    get:
      responses: {}

Known false positives

None known. A deliberately flat template such as /{org}/{repo} is reported and has to be suppressed per path.

func NoDefaultForRequiredParameter

func NoDefaultForRequiredParameter() Rule

NoDefaultForRequiredParameter returns the extra-no-default-for-required-parameter rule.

What it checks

A parameter with required: true must not have a default value in its schema. Both operation parameters (including those declared on the path item) and reusable parameters under components.parameters are checked, and the schema is resolved through local $ref. The finding is reported on the default keyword when the schema is inline, and on the schema otherwise.

Why

A default is the value a server assumes when the client omits the parameter. A required parameter can never be omitted, so the default is dead documentation that suggests the parameter is optional and misleads generated clients and mock servers.

Where it comes from

IBM's API Handbook ruleset (ibm-no-default-for-required-parameter) and the openapilint rule required-parameter-must-not-have-default. The two are merged; IBM flags any default, openapilint only a truthy one, which is the onlyTruthy option.

Options

  • onlyTruthy (boolean, default false): when true, only a truthy default is reported, so false, 0, the empty string and null are tolerated.

Bad

parameters:
  - name: limit
    in: query
    required: true
    schema:
      type: integer
      default: 10

Good

parameters:
  - name: limit
    in: query
    required: false
    schema:
      type: integer
      default: 10

Known false positives

None known. A parameter whose schema lives in content rather than schema is not inspected.

func NoEvalInTitle

func NoEvalInTitle() Rule

NoEvalInTitle returns the extra-no-eval-in-title rule.

What it checks

No title or description string anywhere in the document may contain the text eval( , compared case-insensitively. Documentation text is rendered by many tools and some of them evaluate or template strings; a description containing a call to eval is a known vector for script injection in such renderers, and it is never legitimate prose. Only scalar values of keys named title or description are examined, so a property that is itself called description (a mapping) is not mistaken for text.

Where it comes from

Speccy and the OpenAPI Kit (oas-kit) linters, which both reject eval( in descriptions and titles.

Options

None.

Bad

info:
  title: Pets
  description: Call eval(x) to start

Good

info:
  title: Pets
  description: Evaluate the request before sending it

Known false positives

A genuine discussion of the JavaScript eval function in documentation is flagged. An example payload inside a description is flagged too.

func NoInlineSchema

func NoInlineSchema() Rule

NoInlineSchema returns the extra-no-inline-schema rule.

What it checks

The schema of an operation parameter, of a request body media type and of a response media type must be a $ref to a reusable schema instead of an inline definition. Path-level and operation-level parameters are covered; both the schema and the content schema forms of a parameter are checked. Each of the three locations can be switched off by an option.

Why

Code generators and API portals name an inline schema after its position in the document, which yields unstable and unreadable type names such as GetPetsResponse200. Reusable named schemas give stable names, enable reuse and keep the paths section small.

Where it comes from

rate-my-openapi, the three apimatic-no-inline rules for parameter, request body and response schemas, merged into one rule with an option per location.

Options

  • parameters (bool, default true): check parameter schemas.
  • requestBodies (bool, default true): check request body schemas.
  • responses (bool, default true): check response schemas.
  • allowPrimitives (bool, default false): accept inline schemas whose type is a plain string, number, integer or boolean, which have no useful name to extract. Mainly useful for parameters.

Bad

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object

Good

schema:
  $ref: "#/components/schemas/NewPet"

Known false positives and limitations

With the defaults every inline parameter schema is reported, including trivial ones such as type: string; enable allowPrimitives to relax that. Reusable parameters, request bodies and responses declared under components are not checked, since extracting an inline schema out of them is their own refactoring.

func NoLinkHeader

func NoLinkHeader() Rule

NoLinkHeader returns the extra-no-link-header rule.

What it checks

No header parameter and no response header may be named Link. Names are compared case-insensitively. Parameters are read from operations, path items and components.parameters; response headers from operation responses, components.responses and components.headers.

Why

The Link header (RFC 8288) is meant for hypermedia relations and is awkward to consume from JSON based clients, which cannot read it from the payload. Links belong into the JSON body, where they are documented by the schema.

Where it comes from

Zally (AvoidLinkHeadersRule, Zalando guideline 166 "Do Not Use Link Headers with JSON entities").

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          headers:
            Link:
              schema:
                type: string

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  next:
                    type: string

Known false positives / limitations

APIs that return non JSON media types, or that follow a standard such as the GitHub style pagination on purpose, may legitimately use the header.

func NoMixedNumberRangeConstraints

func NoMixedNumberRangeConstraints() Rule

NoMixedNumberRangeConstraints returns the extra-no-mixed-number-range-constraints rule.

What it checks

A port of Redocly CLI's no-mixed-number-range-constraints. A schema is reported when maximum and exclusiveMaximum are both numbers, and when minimum and exclusiveMinimum are both numbers. The finding is placed on the exclusive keyword and reads "Schema should not have both `maximum` and `exclusiveMaximum`. Use one or the other." (or the minimum equivalent).

The test is the one of the original: the values must be numbers (typeof number). In OpenAPI 3.0 exclusiveMaximum and exclusiveMinimum are booleans that modify maximum and minimum; that spelling is therefore never reported, and neither is a bound given as a string. The original applies the check to every OpenAPI version, so a 3.0 document that uses the numeric 3.1 form next to the inclusive bound is reported too.

Why

Numeric exclusive bounds come from JSON Schema 2020-12 (OpenAPI 3.1). Having both an inclusive and an exclusive bound for the same side is redundant at best, and tools disagree about which one wins when they differ.

Where it comes from

Redocly CLI, rule no-mixed-number-range-constraints (packages/core/src/rules/common/no-mixed-number-range-constraints.ts).

Options

None.

Bad

components:
  schemas:
    Age:
      type: integer
      maximum: 10
      exclusiveMaximum: 10

Good

components:
  schemas:
    Age:
      type: integer
      exclusiveMaximum: 10

Known false positives and limitations

Bound values are not compared, exactly as in the original: two bounds that agree are reported as well as bounds that differ.

func NoNestedCallbacks

func NoNestedCallbacks() Rule

NoNestedCallbacks returns the extra-no-nested-callbacks rule.

What it checks

A callback must not contain callbacks of its own. The operations of the path items inside a callback (and inside components/callbacks) are searched for a callbacks object, and each one found is reported, at any depth.

Nested callbacks make a webhook flow hard to follow, are poorly supported by documentation renderers and code generators, and usually indicate that a workflow should be modelled as separate operations.

Where it comes from

Spectral, where the OpenAPI ruleset discourages callbacks inside callbacks.

Options

None.

Bad

paths:
  /subscribe:
    post:
      callbacks:
        onEvent:
          "{$request.body#/url}":
            post:
              callbacks:
                onAck:
                  "{$request.body#/ack}":
                    post:
                      responses: {}

Good

paths:
  /subscribe:
    post:
      callbacks:
        onEvent:
          "{$request.body#/url}":
            post:
              responses: {}

Known false positives

Callbacks and path items that are reached through $ref are inspected only where they are defined (components/callbacks), not at the place that refers to them.

func NoNullableProperties

func NoNullableProperties() Rule

NoNullableProperties returns the extra-no-nullable-properties rule.

What it checks

A property must not be nullable. A property is nullable when its schema, after local $ref resolution, sets nullable: true (OpenAPI 3.0) or lists null in its type (OpenAPI 3.1). Properties are exempt inside request bodies of media type application/merge-patch+json, where null means "remove this field".

Why

Nullable properties force every client to handle three states (absent, null and a value). Omitting an optional property conveys the same information with fewer special cases and without the generator quirks that null causes.

Where it comes from

IBM's API Handbook ruleset (ibm-no-nullable-properties).

Options

None.

Bad

Pet:
  type: object
  properties:
    nickname:
      type: string
      nullable: true

Good

Pet:
  type: object
  properties:
    nickname:
      type: string

Known false positives

A component schema that is only used by a merge-patch request body is flagged, because the exemption applies to schemas written inline below the merge-patch media type. Properties that become nullable through oneOf with a null branch are not detected.

func NoPathItemLevelParameters

func NoPathItemLevelParameters() Rule

NoPathItemLevelParameters returns the extra-no-path-item-level-parameters rule.

What it checks

A path item must not define a parameters list. Parameters declared on the path item apply to every operation of the path, which hides them from the operations that use them and surprises tools that only look at the operation. Every parameter must be declared on the operation itself, which keeps each operation self-describing.

Where it comes from

openapilint, which forbids path-item level parameters.

Options

None.

Bad

paths:
  /pets/{id}:
    parameters:
      - {name: id, in: path, required: true, schema: {type: string}}
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets/{id}:
    get:
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}
      responses:
        "200":
          description: ok

Known false positives

Path parameters repeated on every operation of a path item are the common reason to use this feature; the rule intentionally asks for the repetition.

func NoRefInExample

func NoRefInExample() Rule

NoRefInExample returns the extra-no-ref-in-example rule.

What it checks

A $ref must not appear anywhere inside the value of an example field, at any nesting depth. The rule runs on the document as written, before references are resolved. A $ref is allowed inside examples, whose entries are Example Objects that may be references. Property names that merely happen to be "example" (for instance a schema property called example) are not mistaken for the keyword.

Why

In OpenAPI the example field holds a literal value, not an OpenAPI object. A $ref there is not resolved by compliant tools: it is shown as a literal {"$ref": "..."} object, which is never what the author meant.

Where it comes from

IBM openapi-validator (ibm-no-ref-in-example).

Options

None.

Bad

content:
  application/json:
    example:
      $ref: "#/components/examples/Pet"

Good

content:
  application/json:
    examples:
      pet:
        $ref: "#/components/examples/Pet"

Known false positives and limitations

An example payload that legitimately contains a property called $ref (for instance documentation of a JSON reference format) is flagged. Vendor extension subtrees (x-*) are ignored.

func NoReservedHeaderParameter

func NoReservedHeaderParameter() Rule

NoReservedHeaderParameter returns the extra-no-reserved-header-parameter rule.

What it checks

Header parameters must not be named after a header that OpenAPI describes in other ways. By default the reserved names are Accept, Authorization, Content-Type, If-Modified-Since and If-Unmodified-Since. Names are compared case-insensitively. Parameters are read from operations, path items and components.parameters.

Why

The specification states that a parameter named Accept, Content-Type or Authorization in the header location is ignored: the content negotiation is described by the content maps and the credentials by security schemes. Such a parameter therefore documents something tools silently drop. The conditional request headers are better modeled as dedicated preconditions.

Where it comes from

IBM openapi-validator, which has one rule for each of the Accept, Authorization, Content-Type, If-Modified-Since and If-Unmodified-Since header parameters. They are merged here into one rule with a list option.

Options

  • headers: the reserved header names. Default: Accept, Authorization, Content-Type, If-Modified-Since, If-Unmodified-Since.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: Accept
          in: header
          schema:
            type: string

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json: {}
            text/csv: {}

Known false positives / limitations

APIs that deliberately expose conditional request headers as parameters will see If-Modified-Since and If-Unmodified-Since reported; remove them from the headers option.

func NoUUIDSuffixProperty

func NoUUIDSuffixProperty() Rule

NoUUIDSuffixProperty returns the extra-no-uuid-suffix-property rule.

What it checks

A property whose name ends in _uuid and whose schema is an inline plain string with format uuid (no pattern, enum, minLength or maxLength, and not a $ref) is flagged: the name should end in _id instead.

Why

Identifiers are opaque to clients. Encoding the representation (uuid) in the name leaks an implementation detail and makes it a breaking change to switch to another identifier format later, so project_uuid should be project_id.

Where it comes from

The Oxide OpenAPI lint (uuid properties must not end with _uuid).

Options

None.

Bad

components:
  schemas:
    Instance:
      type: object
      properties:
        project_uuid:
          type: string
          format: uuid

Good

components:
  schemas:
    Instance:
      type: object
      properties:
        project_id:
          type: string
          format: uuid

Known false positives / limitations

Properties that reference a shared uuid schema with $ref, or constrain the string with a pattern or length, are intentionally not reported (matching the source linter), even though they carry the same naming problem.

func NoWhitespaceInExampleKeys

func NoWhitespaceInExampleKeys() Rule

NoWhitespaceInExampleKeys returns the extra-no-whitespace-in-example-keys rule.

What it checks

The keys of the examples map of a media type in a response must not contain whitespace. Operation responses and components/responses are inspected, and the content of every media type is covered.

The key of a named example is an identifier. Whitespace in it makes the key awkward to reference, to use as a generated identifier and to type in tools that list the examples; a summary field exists for the human readable label.

Where it comes from

IBM openapi-validator, rule ibm-no-whitespace-in-example-keys, a pattern check that rejects keys with whitespace.

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              examples:
                a pet:
                  value: {}

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              examples:
                a-pet:
                  summary: A pet
                  value: {}

Known false positives

Only response examples are inspected; examples of request bodies and parameters are not.

func NoWildcardMediaType

func NoWildcardMediaType() Rule

NoWildcardMediaType returns the extra-no-wildcard-media-type rule.

What it checks

No content map may use the media type */*. The check covers the content of parameters, request bodies and responses, whether they are inline or defined under components (parameters, requestBodies, responses, headers). One finding is reported per wildcard key.

Why

A wildcard says nothing about the representation of the payload. Clients cannot choose a parser, generators cannot pick a type and content negotiation becomes guesswork. Declare the concrete media types that the API supports.

Where it comes from

IBM's API Handbook ruleset (ibm-content-contains-schema family; the wildcard restriction of ibm-valid-media-type).

Options

None.

Bad

requestBody:
  content:
    "*/*":
      schema:
        type: object

Good

requestBody:
  content:
    application/json:
      schema:
        type: object

Known false positives

Only the full wildcard */* is reported. Partial wildcards such as image/* are accepted. File download endpoints that return arbitrary content legitimately use */* and need to be suppressed.

func NullableBodySchema

func NullableBodySchema() Rule

NullableBodySchema returns the extra-nullable-body-schema rule.

What it checks

The schema of a request body media type must not be nullable. Both the OpenAPI 3.0 nullable: true flag and an OpenAPI 3.1 type list that includes null are reported. A body that may be null cannot be told apart from an absent body in many clients and servers; when a body is optional, mark the request body as not required, and when a member is optional, make it an optional property of an object. The schema is followed through a local $ref before it is inspected, and the finding is reported at the media type schema. Request bodies declared in components are checked as well.

Where it comes from

Oxide's OpenAPI lint, which asks for a struct with an optional member instead of a nullable request body.

Options

None.

Bad

requestBody:
  content:
    application/json:
      schema:
        type: object
        nullable: true

Good

requestBody:
  required: false
  content:
    application/json:
      schema:
        type: object

Known false positives

Nullability inside the body (properties, items) is not reported, and neither is nullability introduced only through allOf, anyOf or oneOf branches.

func NullableRequiresType

func NullableRequiresType() Rule

NullableRequiresType returns the extra-nullable-requires-type rule.

What it checks

A schema that carries the nullable keyword must also declare a type next to it. Every schema of the document is inspected: component schemas, parameter, request body and response schemas and everything nested below them.

Why

In OpenAPI 3.0 nullable only modifies the type of the same schema object. The specification states that nullable: true without a sibling type has no effect, so a schema such as an allOf wrapper with nullable: true silently stays non-nullable in tools that follow it, while other tools assume the opposite.

Where it comes from

Redocly CLI and speakeasy (nullable requires a sibling type).

Options

None.

Bad

components:
  schemas:
    Owner:
      nullable: true
      allOf:
        - $ref: "#/components/schemas/User"

Good

components:
  schemas:
    Owner:
      type: object
      nullable: true
      allOf:
        - $ref: "#/components/schemas/User"

Known false positives and limitations

OpenAPI 3.1 removed nullable in favour of type arrays; the keyword is still flagged there when it appears without a type, which is a leftover to clean up as well. A type declared only inside an allOf member is not seen as a sibling type.

func OAuth2RefreshURL

func OAuth2RefreshURL() Rule

OAuth2RefreshURL returns the extra-oauth2-refresh-url rule.

What it checks

Every flow of an oauth2 security scheme except clientCredentials must define a refreshUrl. The flows examined are implicit, password and authorizationCode, found under components.securitySchemes.

Why

Access tokens are short lived. Without a refresh endpoint clients cannot renew them and have to send the user through the authorization again. Client credentials flows have no user to bother, so a new token is simply requested again.

Where it comes from

The Spectral OWASP ruleset, rule owasp:api2:2023-short-lived-access-tokens, which runs given $.components.securitySchemes[?(@ && @.type=="oauth2")].flows[?(@property != "clientCredentials")] and requires a truthy refreshUrl field, with error severity.

Options

None.

Bad

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://auth.example.com/authorize
          tokenUrl: https://auth.example.com/token
          scopes: {}

Good

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://auth.example.com/authorize
          tokenUrl: https://auth.example.com/token
          refreshUrl: https://auth.example.com/refresh
          scopes: {}

Known false positives / limitations

A refresh endpoint that is the same as the token endpoint is still reported unless refreshUrl is set explicitly. An empty refreshUrl counts as missing (truthy semantics). Only schemes declared inline under components are read ($ref schemes are followed, as the original sees the dereferenced document).

func OAuth2ScopeNamePattern

func OAuth2ScopeNamePattern() Rule

OAuth2ScopeNamePattern returns the extra-oauth2-scope-name-pattern rule.

What it checks

Two checks, both from the same Zally rule.

First, every scope declared by an oauth2 security scheme (under components.securitySchemes.*.flows.*.scopes) must match, in full, the configured regular expression. The default accepts the scope uid and scopes of the form <app>.read, <app>.write and <area>.<app>.read or .write, where the segments are lower-case letters and hyphens. Scope names listed in the allowed option are exempt.

Second, every operation must be secured by scopes. The security requirements of the operation apply, or those of the document when the operation has none (an empty security array counts as none). The operation is reported when:

  • there is no security requirement at all (Endpoint is not secured by scope(s)),
  • a requirement names a scheme that is not in components.securitySchemes,
  • a requirement names an oauth2 scheme and lists no scopes, or
  • it lists a scope that no flow of that scheme declares.

Schemes that are not oauth2 are not checked for scopes. Paths that match one of the pathWhitelist expressions anywhere in the route are skipped by the second check.

Why

Consistent scope names make permissions predictable for API consumers and let gateways map scopes to resources mechanically, and an endpoint without scopes cannot be granted or denied individually.

Where it comes from

Zally rule 105, "Secure All Endpoints With Scopes" (SecureAllEndpointsWithScopesRule), with its scope_regex and path_whitelist settings and its two checks checkDefinedScopeFormats and checkOperationsAreScoped.

Options

  • pattern (string, default ^(uid)|(([a-z-]+\.){1,2}(read|write))$): the expression every scope name must match in full. An invalid expression disables the scope name check.
  • allowed (list of strings, default empty): scope names that are always accepted by the name check.
  • pathWhitelist (list of strings, default empty): regular expressions; an operation whose route contains a match is not checked for scopes. An invalid expression is ignored.
  • allowExplicitPublic (bool, default true): do not report an operation that sets security: [] itself. Set it to false to require scopes on those operations too, as the original Zally rule does.

Bad

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://example.com/auth
          scopes:
            admin: Administrator

Good

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://example.com/auth
          scopes:
            pets.read: Read pets

Known false positives / limitations

Scope names used in requirements are also checked by extra-security-scopes-defined; the two rules overlap by design. Expressions use the Go regexp syntax (RE2). Only the four standard flows are read, as in the original.

func Openapi31AllowedSchemaKeywords

func Openapi31AllowedSchemaKeywords() Rule

Openapi31AllowedSchemaKeywords returns the extra-openapi31-allowed-schema-keywords rule.

What it checks

In an OpenAPI 3.1 document every keyword of a schema object must be in an allow-list, or be an extension that starts with x-. By default the list is the full vocabulary of OpenAPI 3.1 and JSON Schema 2020-12 (const, propertyNames, prefixItems, if/then/else, $schema, $defs, deprecated, xml and so on), so the rule reports only keywords that are not part of the specification, such as the OpenAPI 3.0 nullable or a misspelt keyword. The rule only applies to 3.1 documents.

Set profile to ibm for the restricted vocabulary of IBM's ibm-schema-keywords, which keeps a 3.1 document convertible to 3.0: the keywords OpenAPI 3.0 already knew (without nullable), plus patternProperties and unevaluatedProperties. Everything else that JSON Schema 2020-12 added is then reported.

Where it comes from

IBM openapi-validator, rule ibm-schema-keywords.

Options

  • profile (string, default oas31): oas31 allows every OpenAPI 3.1 and JSON Schema 2020-12 keyword; ibm allows only the IBM list ($ref, additionalProperties, allOf, anyOf, default, description, discriminator, enum, example, examples, exclusiveMaximum, exclusiveMinimum, format, items, maximum, maxItems, maxLength, maxProperties, minimum, minItems, minLength, minProperties, multipleOf, not, oneOf, pattern, patternProperties, properties, readOnly, required, title, type, uniqueItems, unevaluatedProperties, writeOnly).
  • allowedKeywords (list of strings, no default): the allowed keywords; when set it replaces the profile.

Bad

openapi: 3.1.0
components:
  schemas:
    Kind:
      type: string
      nullable: true

Good

openapi: 3.1.0
components:
  schemas:
    Kind:
      type: string
      enum: [cat]

Known false positives

With the ibm profile, keywords that are valid in OpenAPI 3.1 but missing from the IBM list, such as deprecated, xml, externalDocs and $schema, are reported. Use the default profile or extend allowedKeywords when they are wanted. Only schemas reachable from the document body are inspected, not those below $defs of external files.

func Operation2xxRequired

func Operation2xxRequired() Rule

Operation2xxRequired returns the extra-operation-2xx-required rule.

What it checks

Every operation must declare at least one successful response: a response key that starts with 2, such as 200, 204 or the range 2XX. Responses that only use 3xx, 4xx, 5xx or default do not satisfy the rule. The finding is reported on the responses object, or on the operation when it has none.

Why

An operation with no documented success outcome tells clients nothing about what a good call returns, and SDK generators cannot choose a return type.

Where it comes from

ai-api-lint (the operation must define a 2xx response).

Options

None.

Bad

responses:
  "404":
    description: Not found

Good

responses:
  "200":
    description: ok

Known false positives

Redirect-only endpoints, which answer 302 by design, and webhook callbacks documented with a default response are flagged. Operations below webhooks and callbacks are not inspected.

func OperationDescriptionMinChars

func OperationDescriptionMinChars() Rule

OperationDescriptionMinChars returns the extra-operation-description-min-chars rule.

What it checks

For every operation that has a description, a summary or both, the longer of the two (after trimming white space, counted in characters) must be at least the configured length. Operations with neither field are not reported here; other rules require the fields to exist. One-word summaries such as "Get" teach neither people nor language models how the operation behaves, so at least one of the two texts must say something substantial.

Where it comes from

ai-api-lint, which checks that operation text is long enough to be useful.

Options

  • minLength: minimum number of characters. Default: 30. A value of zero or less disables the rule.

Bad

paths:
  /pets:
    get:
      summary: List pets

Good

paths:
  /pets:
    get:
      summary: List pets
      description: Returns every pet that the caller is allowed to see.

Known false positives

Short but complete texts in languages with dense scripts (for example Chinese) may be flagged because the length is counted in characters.

func OperationDescriptionOpensWithSentence

func OperationDescriptionOpensWithSentence() Rule

OperationDescriptionOpensWithSentence returns the extra-operation-description-opens-with-sentence rule.

What it checks

The description of an operation must open with a plain sentence: its first non-blank line must not start with Markdown or HTML structure. The flagged openings are a heading (#), a block quote (>), a list item (-, *, +, 1. or 1)), a table row (|), a code fence (``` or ~~~), an indented code block (a tab or four spaces) and an HTML tag.

Why

Many tools use the beginning of the description as a short excerpt: reference documentation shows the first line in navigation and search results, and language-model tooling uses it as the operation blurb. An opening heading, list or code block yields an empty or garbled excerpt.

Where it comes from

Redocly CLI (operation-description-opens-with-sentence).

Options

None.

Bad

paths:
  /pets:
    get:
      description: |
        ## Overview
        Lists the pets.

Good

paths:
  /pets:
    get:
      description: |
        Lists the pets.

        ## Details

Known false positives and limitations

Only the start of the description is examined, with a line based test, so a description that begins with a sentence which happens to start with a number and a period ("2. Run it") is read as a list. Operations with no description are not reported.

func OperationDescriptionRestatesPath

func OperationDescriptionRestatesPath() Rule

OperationDescriptionRestatesPath returns the extra-operation-description-restates-path rule.

What it checks

The description and the summary of an operation must say more than the request line. They are reported when, lower-cased and trimmed, they equal the path alone, the method followed by a space and the path ("get /pets"), or the method directly followed by the path ("get/pets").

Why

A description that repeats the method and path tells readers nothing they do not already see in the document, and is a typical placeholder left behind by generators. Agents and developers rely on descriptions to decide what an operation does.

Where it comes from

ai-api-lint (AI012, description repeats the HTTP method and path).

Options

None.

Bad

paths:
  /pets:
    get:
      summary: GET /pets

Good

paths:
  /pets:
    get:
      summary: List all pets

Known false positives / limitations

Only exact restatements are found; "Gets /pets" or a description that merely contains the path is accepted.

func OperationIDCasing

func OperationIDCasing() Rule

OperationIDCasing returns the extra-operation-id-casing rule.

What it checks

The operationId of every operation must follow a case convention, snake_case by default. The shared casing option selects one or more of the conventions of the internal casing package. With strictCharset the operationId must in addition consist only of letters, digits and underscores, which rejects hyphens, dots and other separators regardless of the style.

Why

Operation identifiers become method and function names in generated clients. A single convention yields uniform names, and a restricted character set guarantees that the identifier is a legal name in every target language.

Where it comes from

The IBM API Handbook ruleset and the Oxide OpenAPI lint (operationId casing, configurable through the Spectral casing function) and ai-api-lint (operation-id-charset-strict). The two rows are merged.

Options

  • casing (string or list, default "snake_case"): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A list accepts an identifier that follows any of them, an empty list disables the casing check and an unknown value is reported.
  • strictCharset (bool, default false): require [a-zA-Z0-9_]+.

Bad

paths:
  /pets:
    get:
      operationId: listPets

Good

paths:
  /pets:
    get:
      operationId: list_pets

Known false positives / limitations

Digits are allowed anywhere after the first letter. Acronym runs such as getHTTPStatus pass the camel check but would fail a strict word-based one.

func OperationIDMaxLength

func OperationIDMaxLength() Rule

OperationIDMaxLength returns the extra-operation-id-max-length rule.

What it checks

The operationId of every operation must not be longer than a limit, counted in characters. Operations without an operationId are ignored; use operation-operationId to require one.

The operationId becomes a method or function name in generated clients, a tool name for agents and a file name in some tooling. Very long identifiers are truncated or rejected by many of them (several LLM tool-calling APIs cap names at 64 characters) and are unpleasant to read.

Where it comes from

ai-api-lint and rate-my-openapi, which flag operationIds longer than 64 characters.

Options

  • maxLength (int, default 64): the longest accepted operationId. A value of zero or less disables the rule.

Bad

With maxLength set to 10:

paths:
  /pets:
    get:
      operationId: listAllThePetsInTheStore

Good

paths:
  /pets:
    get:
      operationId: listPets

Known false positives

None known. The length is measured in characters, not bytes.

func OperationIDMaxPrefixes

func OperationIDMaxPrefixes() Rule

OperationIDMaxPrefixes returns the extra-operation-id-max-prefixes rule.

What it checks

The lowercase prefix before the first uppercase letter of every operationId (getPet gives get, listPets gives list) is collected across the whole document. When more distinct prefixes are used than the allowed maximum, one finding is reported on the document root, listing the prefixes. operationIds without an uppercase letter after a lowercase prefix, such as list_pets, are ignored.

Why

Consistent verbs make an API predictable and are what tool-calling agents and SDK users rely on to guess method names. A document that mixes get, fetch, retrieve, read, load and obtain for the same idea is harder to use.

Where it comes from

ai-api-lint (AI063, operationId verb prefixes should be consistent).

Options

  • max (integer, default 5): the largest number of distinct prefixes allowed.

Bad

# six or more distinct prefixes, for example:
operationId: getPet
operationId: fetchOwner
operationId: retrieveVet
operationId: loadClinic
operationId: readVisit
operationId: obtainBill

Good

operationId: getPet
operationId: listPets
operationId: createPet

Known false positives

APIs that deliberately use many distinct verbs, such as action-style APIs, exceed the default; raise max for them.

func OperationIDReservedWord

func OperationIDReservedWord() Rule

OperationIDReservedWord returns the extra-operation-id-reserved-word rule.

What it checks

The operationId of an operation must not be a reserved word. By default the reserved words are the keywords of Python (the list reported by keyword.kwlist: False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield). Code generators turn operation ids into function names, so an id such as import or class yields code that cannot be compiled or imported. The comparison is exact and case-sensitive, as the keywords are.

Where it comes from

ai-api-lint, which rejects operation ids that are Python keywords.

Options

  • words: list of reserved words. Default: the Python keywords above. Supply a different list to protect other languages; an empty list disables the rule.

Bad

paths:
  /imports:
    get:
      operationId: import

Good

paths:
  /imports:
    get:
      operationId: listImports

Known false positives

Keywords of languages other than Python are not checked unless configured, and a word that is only reserved in some Python versions is always flagged.

func OperationIDVerbMatchesMethod

func OperationIDVerbMatchesMethod() Rule

OperationIDVerbMatchesMethod returns the extra-operation-id-verb-matches-method rule.

What it checks

A port of the IBM function operationIdNamingConvention, run in its strict mode (as the ibm-operationid-naming-convention rule does). The operationId must be exactly one acceptable verb, an underscore and the resource part of the path, written as snake case words joined by underscores. The accepted verbs depend on the HTTP method and the path shape:

  • GET on a resource-oriented collection path (/bands): list.
  • GET on a path ending in a parameter (/bands/{id}): get, plus check when the path has two or more parameter references.
  • POST on a resource-oriented collection path: create.
  • PATCH: update.
  • PUT: replace, plus add on a path that ends in a parameter and has two or more parameters, or set on a non resource-oriented path that does not end in a parameter but has at least one parameter.
  • DELETE: delete, plus remove (ends in a parameter, two or more parameters) or unset (not resource-oriented, does not end in a parameter, at least one parameter).

GET and POST on paths that are not resource-oriented, and every other method, are not checked. A path counts as resource-oriented when it ends in a parameter (IBM's lookup for the matching collection path never fails, so every such path is treated as resource-oriented) or when another path starts with the path followed by "/{".

The noun part is built as IBM builds it: the path is split on "/", segments that are path parameters are dropped, everything up to and including a version segment (v1, v2, ...) is dropped, and every remaining segment is singularised, except that the last segment stays plural for the verbs list, replace, set, delete, remove and unset when the path does not end in a parameter. Singularisation uses a port of the Rails inflector as shipped in the "inflected" package, including IBM's exceptions that keep metadata, data, media and criteria unchanged. For /bands/{id}/albums/{album_id}, GET must be get_band_album or check_band_album.

In non-strict mode (strict: false) only the verb is checked: the operationId must start with one of the acceptable verbs. Operations without an operationId are skipped.

Why

A predictable verb and noun vocabulary makes generated SDK method names consistent (client.bands.list(), client.bands.create()) and keeps the operationId honest about what the operation does and to which resource.

Where it comes from

IBM openapi-validator (ibm-operationid-naming-convention).

Options

  • strict (bool, default true): require the full verb_resource form. When false only the leading verb is checked.

Bad

paths:
  /bands:
    get:
      operationId: get_bands
  /bands/{id}:
    get:
      operationId: get_bands

Good

paths:
  /bands:
    get:
      operationId: list_bands
  /bands/{id}:
    get:
      operationId: get_band

Known false positives and limitations

The rule is as strict as the original: camelCase identifiers such as listBands and nouns that deviate from the singularised path are reported. The inflector is a port of the English Rails rules, so unusual words follow its (sometimes surprising) results.

func OperationIDVerbPrefix

func OperationIDVerbPrefix() Rule

OperationIDVerbPrefix returns the extra-operation-id-verb-prefix rule.

What it checks

When an operation has an operationId, it must start with one of a list of verbs, written in lower case and followed by an upper-case letter, as in getUser or listOrders. The default verbs are get, list, create, update, delete, remove, search, find, fetch, add, set, check, verify, send, upload, download, export, batch and bulk. Operations without an operationId are ignored; use the operation-operationId rule to require one.

Why

Generated SDK methods, MCP tools and agent function names are derived from the operationId. A leading verb makes the name read as an action, and a fixed vocabulary keeps the names predictable across the API.

Where it comes from

ai-api-lint (AI002, operationId should start with a common verb).

Options

  • prefixes: the accepted verbs. Default: get, list, create, update, delete, remove, search, find, fetch, add, set, check, verify, send, upload, download, export, batch, bulk.

Bad

paths:
  /pets:
    get:
      operationId: pets

Good

paths:
  /pets:
    get:
      operationId: listPets

Known false positives / limitations

An operationId in snake_case or kebab-case (list_pets) never matches, because the verb must be followed by an upper-case letter. Rename the identifiers or disable the rule for such APIs. A bare verb such as "list" is also reported.

func OperationMaxParameters

func OperationMaxParameters() Rule

OperationMaxParameters returns the extra-operation-max-parameters rule.

What it checks

The number of parameters of an operation, counting the parameters inherited from its path item (an operation parameter replaces an inherited one with the same name and location), must not exceed maxParameters, and the number of those parameters marked required: true must not exceed maxRequiredParameters.

Why

Operations with many parameters are hard to call, document and test, and are usually a sign that the endpoint tries to do too much or that a request body or a filter object would describe the input better. Many required inputs make the operation fragile for clients.

Where it comes from

ai-api-lint (operation-max-parameters and operation-max-required-parameters). The two rows are merged.

Options

  • maxParameters (int, default 15): the highest allowed parameter count. Zero or a negative value disables this limit.
  • maxRequiredParameters (int, default 7): the highest allowed number of required parameters. Zero or a negative value disables this limit.

Bad

An operation with sixteen query parameters, or eight required ones.

Good

paths:
  /pets:
    get:
      parameters:
        - name: limit
          in: query
          schema:
            type: integer

Known false positives / limitations

Cookie and header parameters count like query parameters, although they are often cross-cutting and shared by every operation.

func OperationSummaryMaxLength

func OperationSummaryMaxLength() Rule

OperationSummaryMaxLength returns the extra-operation-summary-max-length rule.

What it checks

The summary of an operation must be at most a number of characters long (80 by default). Operations without a summary are ignored.

Summaries are shown in navigation menus, tables and generated method documentation. A short summary stays readable there; long explanations belong in the description field.

Where it comes from

IBM openapi-validator (ibm-operation-summary-length, which limits the summary to 80 characters) and speccy (operation-summary-length).

Options

  • maxLength (int, default 80): the longest accepted summary. A value of zero or less disables the rule.

Bad

With maxLength set to 10:

paths:
  /pets:
    get:
      summary: List every pet that is registered in the store

Good

paths:
  /pets:
    get:
      summary: List pets

Known false positives

None known. The length is measured in characters, not bytes, after the YAML has been decoded, so folded block scalars are counted with their line breaks.

func OperationSummaryRequired

func OperationSummaryRequired() Rule

OperationSummaryRequired returns the extra-operation-summary-required rule.

What it checks

Every operation must have a summary that is not empty and not just whitespace. A missing summary is reported on the operation, an empty one on the summary itself.

Why

The summary is the short label shown in documentation navigation, generated client method comments and tool listings. Without it, tools fall back to the path or operationId, which are rarely suitable for people.

Where it comes from

IBM's API Handbook ruleset (ibm-operation-summary), Redocly (operation-summary) and rate-my-openapi (operation summary), merged into one rule.

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets:
    get:
      summary: List pets
      responses:
        "200":
          description: ok

Known false positives

None known. Operations whose summary is supplied only through a vendor extension are still flagged.

func OptionalBodyWithRequiredProperties

func OptionalBodyWithRequiredProperties() Rule

OptionalBodyWithRequiredProperties returns the extra-optional-body-with-required-properties rule.

What it checks

A request body that is optional (its required flag is absent or false) must not use a schema that lists required properties. Such a body can be omitted entirely, yet when it is sent it must contain the required members, which is rarely the intent and leaves clients unsure whether to send an empty object. The schema is followed through a local $ref, and the required lists of allOf members are taken into account. Request bodies in components are checked as well, and operation request bodies that are $ref references are resolved so that their required flag is read from the component.

Where it comes from

IBM's openapi-validator, which warns when an optional request body requires properties.

Options

None.

Bad

requestBody:
  content:
    application/json:
      schema:
        type: object
        required: [name]
        properties:
          name:
            type: string

Good

requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        required: [name]
        properties:
          name:
            type: string

Known false positives

A body that is deliberately optional but needs certain members when it is present (a partial update) is flagged. Required members reachable only through anyOf or oneOf are not considered.

func PaginationParametersShape

func PaginationParametersShape() Rule

PaginationParametersShape returns the extra-pagination-parameters-shape rule.

What it checks

A GET operation is a paginated list operation when all of these hold: its path does not end in a path parameter; its first success response (the first response code that starts with 2) has an application/json media type whose schema, with allOf members merged, has properties and at least one of them is an array schema; and the operation itself declares parameters including an offset query parameter or one page token query parameter named start, token, cursor, page or page_token. Parameters inherited from the path item are not considered, as in the original. For such an operation:

  • A limit query parameter must be an integer schema, optional, and have a default and a maximum that are both truthy (a default or maximum of 0 counts as missing, exactly like the original).
  • An offset query parameter must be an integer schema and optional.
  • An offset parameter requires a limit parameter (reported on the operation).
  • The page token parameter (the first matching one) should be named start, and must be a string schema and optional.
  • When there is a limit parameter, the response schema must have a limit property that is an integer and is listed in required; likewise offset for an offset parameter.
  • A total_count response property, when present, must be an integer and listed in required.
  • The response must have first and next properties, and may have last and previous; each present one must be an object with an href string property (allOf merged).

Schema checks use the IBM composition semantics: a type test holds for a schema when the schema, any allOf member, all members of a oneOf, or all members of an anyOf satisfies it. required lists of all allOf members are merged.

Why

Pagination parameters are used by every client of every list endpoint. Letting limit be required, unbounded or untyped, or letting the response omit the values that were applied and the links to other pages, forces each client to special-case each endpoint.

Where it comes from

IBM openapi-validator, ibm-pagination-style (checks 1 to 12; check 7 lives in the separate collection-array-property rule).

Options

None.

Bad

paths:
  /things:
    get:
      parameters:
        - {name: limit, in: query, required: true, schema: {type: integer}}
        - {name: offset, in: query, schema: {type: integer}}

Good

paths:
  /things:
    get:
      parameters:
        - {name: limit, in: query, schema: {type: integer, default: 10, maximum: 100}}
        - {name: start, in: query, schema: {type: string}}
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                required: [limit, first, next, things]
                properties:
                  limit: {type: integer}
                  first: {type: object, properties: {href: {type: string}}}
                  next: {type: object, properties: {href: {type: string}}}
                  things: {type: array, items: {type: string}}

Known false positives and limitations

Local references are followed; external ones are not. Where the original reports every response property check at a fixed application/json path that Spectral remaps for allOf, this rule reports the location where the property (or the response schema for a missing property) is actually written.

func ParamNameVsBodyPropertyName

func ParamNameVsBodyPropertyName() Rule

ParamNameVsBodyPropertyName returns the extra-param-name-vs-body-property-name rule.

What it checks

The name of a parameter of an operation, in any location and including parameters declared on the path item, must not equal the name of a top-level property of the operation's JSON request body schema. The properties of allOf, oneOf and anyOf members are included, $ref targets are followed, and read-only properties are ignored because clients never send them. The JSON request body is the first media type that is application/json or ends in +json.

Why

Many SDK generators flatten parameters and body properties into one argument list. Two inputs with the same name then collide, and the generator either fails or silently drops one of them.

Where it comes from

IBM openapi-validator (ibm-unique-parameter-request-property-names).

Options

None.

Bad

paths:
  /pets/{id}:
    put:
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id: {type: string}

Good

paths:
  /pets/{id}:
    put:
      parameters:
        - {name: id, in: path, required: true, schema: {type: string}}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name: {type: string}

Known false positives / limitations

Only top-level properties are compared, and the comparison is case-sensitive. Non JSON request bodies are ignored.

func ParameterNameConstraints

func ParameterNameConstraints() Rule

ParameterNameConstraints returns the extra-parameter-name-constraints rule.

What it checks

The name of every parameter (operation, path item and components.parameters) must contain at least minLength characters, at most maxLength characters and, when pattern is set, match that regular expression.

Why

Empty parameter names make a parameter unusable, extremely long names are almost always mistakes, and a charset restriction (for example the RFC 6570 variable name characters) keeps names valid in URI templates and in the identifiers of generated clients.

Where it comes from

Speccy and oas-kit (parameter-name-charset, shipped disabled with an empty pattern), and rate-my-openapi (parameter-name-max-length, limited to 50 characters, and parameter-name-nonempty). The three rows are merged.

Options

  • pattern (string, default empty): expression every name must match. An empty or invalid expression disables the charset check.
  • maxLength (int, default 50): longest allowed name. Zero disables it.
  • minLength (int, default 1): shortest allowed name. Zero disables it.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: ""
          in: query
          schema:
            type: string

Good

paths:
  /pets:
    get:
      parameters:
        - name: limit
          in: query
          schema:
            type: integer

Known false positives / limitations

A parameter without a name key is not reported here; a missing name is a structural error for the OpenAPI validation rules. Lengths count characters, not bytes. Expressions use the Go regexp syntax (RE2).

func ParameterSchemaTypeRequired

func ParameterSchemaTypeRequired() Rule

ParameterSchemaTypeRequired returns the extra-parameter-schema-type-required rule.

What it checks

Every parameter of a path item or an operation must have a schema whose type is declared. A parameter is reported when it has no schema at all (which is the case for parameters that use content instead of schema), or when the schema, after following a local $ref, has no type or an empty type. Path item parameters are checked once, and operation parameters are checked on their own, so a parameter is never reported twice.

Clients and tool descriptions are generated from the type of a parameter. Without it, agents and code generators have to guess whether a value is a string, a number or a list.

Where it comes from

ai-api-lint, which requires every operation parameter to have schema.type.

Options

None.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: limit
          in: query
          schema:
            minimum: 1

Good

paths:
  /pets:
    get:
      parameters:
        - name: limit
          in: query
          schema:
            type: integer

Known false positives

A schema that is a composition (oneOf, anyOf, allOf) without its own type is reported, and so is every parameter that uses content. Parameters under components/parameters that no operation uses are not checked.

func PatchContentType

func PatchContentType() Rule

PatchContentType returns the extra-patch-content-type rule.

What it checks

The request body of a PATCH operation may offer only the patch media types: application/json-patch+json and application/merge-patch+json. Any other key of the request body content map, such as application/json, is reported. Parameters after a semicolon and letter case are ignored. $ref request bodies are resolved.

Why

A PATCH body is a description of a change, not a representation of the resource. Declaring it as plain application/json hides which patch format the server understands, so clients cannot know whether to send a JSON Patch document or a merge patch.

Where it comes from

IBM's API Handbook ruleset (ibm-patch-request-content-type).

Options

  • allowed (list of strings, default application/json-patch+json and application/merge-patch+json): the accepted media types.

Bad

patch:
  requestBody:
    content:
      application/json:
        schema: {type: object}

Good

patch:
  requestBody:
    content:
      application/merge-patch+json:
        schema: {type: object}

Known false positives

APIs that implement PATCH with a vendor media type are flagged unless the type is added to the allowed option.

func PathHTTPVerbsOrder

func PathHTTPVerbsOrder() Rule

PathHTTPVerbsOrder returns the extra-path-http-verbs-order rule.

What it checks

Within one path item the operations must appear in the configured order of HTTP methods. A fixed order makes documents predictable to read and keeps diffs small. Each operation that appears after an operation that should follow it is reported at that operation. Methods missing from the configured order are ignored.

Where it comes from

Redocly CLI's path-http-verbs-order rule.

Options

  • order: list of lower-case HTTP methods. Default: get, head, post, put, patch, delete, options, trace. An empty list disables the rule.

Bad

paths:
  /pets:
    post:
      responses: {}
    get:
      responses: {}

Good

paths:
  /pets:
    get:
      responses: {}
    post:
      responses: {}

Known false positives

Documents that group operations by importance or lifecycle rather than by verb are flagged wholesale; configure the order option or disable the rule.

func PathItemSummaryOrDescription

func PathItemSummaryOrDescription() Rule

PathItemSummaryOrDescription returns the extra-path-item-summary-or-description rule.

What it checks

Every path item must have a non-blank summary or description of its own. A path item given by $ref is judged by the item it points at, and paths whose key starts with x- are skipped.

Why

The summary and description of a path item are inherited by all its operations in documentation tools. Describing the resource once, at path level, explains what a route is for independently of the individual verbs.

Where it comes from

oas-kit (path-item-summary-or-description, shipped disabled by default there because many documents only describe operations). It is a candidate for organisations that want resource level documentation.

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets:
    summary: The pets of the store
    get:
      responses:
        "200":
          description: ok

Known false positives and limitations

The summary and description of the operations are not considered, so a path whose operations are all documented is still reported. Path-level summary and description are only available in OpenAPI 3; in Swagger 2 documents the rule reports every path item.

func PathParamPlacement

func PathParamPlacement() Rule

PathParamPlacement returns the extra-path-param-placement rule.

What it checks

Two placement rules for path parameters in the keys of the paths object. A path must not start with a path parameter (/{id}/pets), and a segment that holds a path parameter must consist of the parameter only: text before or after the braces (/pets/id-{id}, /files/{name}.json) is reported.

Why

A path that starts with a parameter cannot be told apart from any other first segment and makes routing and gateway rules ambiguous. A parameter mixed with literal text in one segment is hard to document, is not supported by every router and breaks tools that treat each segment as one value.

Where it comes from

Zally path guidelines (the 129 kebab-case path segment rule and 143 resource identifier rule family), which do not restrict where a parameter sits. There is no upstream implementation; the check is the structural guard that the pattern (^/\{)|[^/]\{|\}[^/] expresses: a route must not match it. This rule reproduces that pattern on segments, so it reports exactly the routes that the pattern matches, and it names the problem.

Options

None.

Bad

paths:
  /{tenant}/pets: {}
  /pets/id-{id}: {}

Good

paths:
  /tenants/{tenant}/pets: {}
  /pets/{id}: {}

Known false positives / limitations

APIs that deliberately use a file extension on a parameter (/reports/{id}.csv) are reported; suppress the rule for those paths. A path with a base path in the server URL is judged by its own text only.

func PathParameterCase

func PathParameterCase() Rule

PathParameterCase returns the extra-path-parameter-case rule.

What it checks

Every variable of a URI template in a path key, such as petId in /pets/{petId}, must follow the configured case style. The shared casing option selects the convention, snake_case by default.

Why

Path variables appear in generated client signatures and in documentation. A single case style across the API makes URIs predictable and avoids mixed spellings such as /pets/{pet_id} next to /owners/{ownerId}.

Where it comes from

apilint (path parameter case) and the Oxide OpenAPI lint (path parameters must be snake case). The two sources are merged into a configurable rule.

Options

  • casing (string or list, default "snake_case"): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A list accepts a variable that follows any of them, an empty list disables the rule and an unknown value is reported.

Bad

paths:
  /pets/{petId}:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets/{pet_id}:
    get:
      responses:
        "200":
          description: ok

Known false positives / limitations

Only the template variables in the path key are checked; the name field of the matching path parameter is not. Digits are allowed after the first letter.

func PathSegmentCase

func PathSegmentCase() Rule

PathSegmentCase returns the extra-path-segment-case rule.

What it checks

The shape of every path template is checked:

  • the path must start with a slash;
  • the path must not end with a slash (the root path / is allowed);
  • the path must not contain empty segments (a double slash);
  • every literal segment must follow the configured case convention.

A segment that contains a path parameter in braces is skipped, so /pets/{petId} only checks pets.

Consistent URL casing makes an API predictable, and a trailing slash or empty segment makes two URLs address the same resource in the eyes of some servers and not of others.

Where it comes from

openapilint and apilint, which check that paths start with a slash, have no trailing slash and no empty segments, and that segments use one casing.

Options

  • casing (string or list, default "kebab-case"): kebab-case, snake_case, camelCase, PascalCase, SCREAMING_SNAKE_CASE, SCREAMING-KEBAB-CASE, dot.case or lowercase. A list accepts a segment that follows any of them, an empty list skips the segment check (the shape checks remain) and an unknown value is reported.

Bad

paths:
  /petOwners/:
    get:
      responses: {}

Good

paths:
  /pet-owners:
    get:
      responses: {}

Known false positives

Segments with a file extension such as openapi.json contain a dot and do not match any case convention, so they are reported. Version segments such as v1 and v2.1 are only accepted when they match the chosen convention.

func PathSegmentParamOnly

func PathSegmentParamOnly() Rule

PathSegmentParamOnly returns the extra-path-segment-param-only rule.

What it checks

A path segment that contains a parameter reference must consist of that reference and nothing else. /pets/{petId} is fine; /pets/pet_{petId}, /files/{name}.json and /a/{x}{y} are reported, once per offending segment, on the path item. A segment with an unbalanced brace is reported too.

Why

Mixing literals and parameters in one segment makes the template hard to match in routers, proxies and gateways and complicates parameter serialisation. Put the variable part in its own segment or into a query parameter.

Where it comes from

IBM's API Handbook ruleset (ibm-path-segment-param-only).

Options

None.

Bad

paths:
  /files/{name}.json:
    get: {}

Good

paths:
  /files/{name}:
    get: {}

Known false positives

File-extension style routes such as /reports/{id}.pdf are flagged although some APIs use them for content negotiation; prefer the Accept header.

func PathSegmentPlural

func PathSegmentPlural() Rule

PathSegmentPlural returns the extra-path-segment-plural rule.

What it checks

Every segment of every path template must be a plural noun, as in /pets/{petId}/toys. Collections are named in the plural so that the same segment reads naturally for the collection (/pets) and for one of its members (/pets/{petId}). A segment that is entirely a path parameter ({petId}) is skipped. Every other segment, including version segments such as v1, segments with a dot and hyphenated, snake_case or camelCase compounds, is judged as a whole word, exactly as Redocly CLI does, by a port of the pluralize library (blakeembrey/pluralize) that Redocly uses: a segment is singular when the library's singularisation rules leave it unchanged, which includes the library's uncountable words (sheep, analytics, news, ...) that have no distinct plural: like Redocly, the rule reports them unless they are listed in exceptions. The port contains the library's complete irregular word table (person/people, child/children, foot/feet, schema/schemata, ...), its uncountable word list and uncountable patterns (information, equipment, news, series, software, analytics, anything ending in fish, sheep, deer or -ese, ...), its singularisation rules, and its pluralisation rules, which are used to suggest the plural in the message. Segments that are empty (a trailing slash) are skipped.

Where it comes from

Redocly CLI's path-segment-plural rule (ignoreLastPathSegment and exceptions options, behaviour of pluralize.isSingular) and apilint's resource-path-plural rule, merged into one. apilint uses a different inflection library and scope: it checks only resource names and exempts the last sub-resource; the onlyCollectionSegments option approximates that scope.

Options

  • ignoreLastPathSegment: when true the last segment of each path is not checked (useful for action endpoints such as /pets/lookup). Default: false.
  • exceptions: list of segments that are allowed to be singular, compared exactly and case-sensitively as in Redocly. Default: empty. Add v1, v2 and similar version segments here, as Redocly requires.
  • onlyCollectionSegments: when true only segments that are directly followed by a path parameter segment are checked, which restricts the rule to resource collections. Default: false.

Bad

paths:
  /pet/{petId}:
    get:
      responses: {}

Good

paths:
  /pets/{petId}:
    get:
      responses: {}

Known false positives

Like the library it ports, the inflector has no dictionary: singular words that end in s (status, address, bus) are judged as plural or singular by pattern only, and words such as "lookup", "search" or "v1" are singular and are reported unless listed in exceptions. Words that are plural in the domain but singular in English must be listed too. The port was written from the library's published rule tables and may differ from it for rare words.

func PatternAnchored

func PatternAnchored() Rule

PatternAnchored returns the extra-pattern-anchored rule.

What it checks

Every pattern keyword of a string schema must start with ^ and end with an unescaped $. Schemas are found in parameters, request bodies, responses and components, nested properties, items and the members of allOf, anyOf and oneOf included. A schema without a type is checked as well (it is typically a composition member); a schema whose type is declared and does not include string is skipped.

Why

JSON Schema patterns are not anchored: they match anywhere in the value. A pattern such as [a-z]+ accepts "123abc456", which is almost never intended, and unanchored patterns make validators and generated clients disagree with the author. Anchoring states exactly which values are accepted.

Where it comes from

IBM openapi-validator (ibm-pattern-properties and string-attributes patterns guidance; the anchoring requirement).

Options

  • requireStart (bool, default true): the pattern must start with ^.
  • requireEnd (bool, default true): the pattern must end with an unescaped $.

Bad

components:
  schemas:
    Code:
      type: string
      pattern: "[A-Z]{3}"

Good

components:
  schemas:
    Code:
      type: string
      pattern: "^[A-Z]{3}$"

Known false positives and limitations

Patterns that are deliberately unanchored for substring matching are flagged; disable requireStart or requireEnd, or suppress the rule. Only the first and last character are examined: an alternation such as ^a|b$ is accepted although it is not anchored as a whole. The pattern is never compiled.

func PatternLengthSatisfiable

func PatternLengthSatisfiable() Rule

PatternLengthSatisfiable returns the extra-pattern-length-satisfiable rule.

What it checks

A string schema that has a pattern together with minLength or maxLength must be satisfiable: at least one string of an allowed length must be able to match the pattern. The rule computes the shortest and longest string the pattern can match, in characters, and compares that range to the length constraints. A pattern that can only match strings shorter than minLength or longer than maxLength, or that no string of an allowed length can satisfy, is reported. Anchors are taken into account: a pattern anchored at both ends matches only strings within its own length range, while an unanchored pattern also matches longer strings that merely contain a match.

Why

A pattern and length limits that exclude each other make the schema reject every value. The mistake is easy to make when a limit is changed without the pattern, and it is only noticed when clients can no longer send valid data.

Where it comes from

Specmatic (generation of values from a pattern that satisfy minLength and maxLength).

Options

None.

Bad

components:
  schemas:
    Code:
      type: string
      pattern: "^[A-Z]{3}$"
      minLength: 5

Good

components:
  schemas:
    Code:
      type: string
      pattern: "^[A-Z]{3}$"
      minLength: 3
      maxLength: 3

Known false positives / limitations

The pattern is compiled to an RE2 automaton and searched exhaustively, length by length, over the character classes of the pattern (one representative character per distinct class boundary), so contradictory classes, anchors and repetition counts are all found, not only the length range. Word boundaries are assumed to be satisfiable. The pattern is parsed as an RE2 expression; patterns that use ECMA 262 features that RE2 lacks (look-ahead, look-behind, back-references) cannot be parsed and are skipped, and so are invalid patterns. When the search would need more than a few thousand lengths or automaton states the pattern is assumed to be satisfiable. Lengths are counted in characters (code points), not UTF-16 units. Multi-line anchors are treated like anchors of the whole text. A schema whose minLength exceeds its maxLength is left to other rules.

func PatternPropertiesRestrictions

func PatternPropertiesRestrictions() Rule

PatternPropertiesRestrictions returns the extra-pattern-properties-restrictions rule.

What it checks

OpenAPI 3.1 only. Where a schema defines patternProperties, the rule requires that it does not also define additionalProperties, that patternProperties is an object with at least one entry and at most one entry, and that the single pattern is anchored with a leading ^ and a trailing $.

Why

Several patterns, or a pattern next to additionalProperties, make it ambiguous which schema applies to a given property name, and many code generators and validators support only a single anchored pattern. Anchoring avoids matching property names by accident.

Where it comes from

The IBM API Handbook ruleset (pattern-properties).

Options

None.

Bad

components:
  schemas:
    Labels:
      type: object
      patternProperties:
        "^a": {type: string}
        "^b": {type: string}

Good

components:
  schemas:
    Labels:
      type: object
      patternProperties:
        "^x-.*$":
          type: string

Known false positives / limitations

The anchoring test is textual (the key starts with ^ and ends with $); an escaped final dollar sign is not distinguished from an anchor.

func PreconditionHeadersOn412

func PreconditionHeadersOn412() Rule

PreconditionHeadersOn412 returns the extra-precondition-headers-on-412 rule.

What it checks

An operation that can return a 412 (Precondition Failed) response must also define at least one conditional request header as a header parameter. The parameters of the path item are taken into account, and parameters are resolved through local $ref. Header names are compared case-insensitively.

A 412 can only be produced when the client sent a precondition. If the operation does not accept any, the response is unreachable and the contract is misleading.

Where it comes from

IBM openapi-validator, rule ibm-precondition-header, which requires operations that return 412 to define If-Match, If-None-Match, If-Modified-Since or If-Unmodified-Since.

Options

  • headers (list of strings, default [If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since]): the header names, at least one of which must be defined.

Bad

paths:
  /pets/{id}:
    put:
      responses:
        "412":
          description: precondition failed

Good

paths:
  /pets/{id}:
    put:
      parameters:
        - name: If-Match
          in: header
          schema:
            type: string
      responses:
        "412":
          description: precondition failed

Known false positives

Preconditions that are announced in another way (for example a custom header that is not in the list) are reported until the headers option is extended.

func PreferTokenPaginationOverOffset

func PreferTokenPaginationOverOffset() Rule

PreferTokenPaginationOverOffset returns the extra-prefer-token-pagination-over-offset rule.

What it checks

A GET operation on a path that does not end in a path parameter is a paginated list operation when its first success response (the first response code that starts with 2) has an application/json media type whose schema, with allOf members merged, has properties of which at least one is an array schema, and the operation itself declares parameters that include a query parameter named offset or a page token query parameter named start, token, cursor, page or page_token. Parameters inherited from the path item are not considered, as in the original. Such an operation that declares a query parameter named exactly offset is reported, at the operation, with the message that token-based pagination is recommended over offset/limit pagination.

Why

Offset pagination skips rows by count. Inserts and deletes between two calls make clients see duplicates or miss items, and large offsets are slow on most databases. Token (cursor) pagination, using a start parameter, stays stable and cheap.

Where it comes from

IBM openapi-validator, ibm-prefer-token-pagination.

Options

None. The names offset and the page token names are fixed, as in the original.

Bad

paths:
  /things:
    get:
      parameters:
        - {name: limit, in: query, schema: {type: integer}}
        - {name: offset, in: query, schema: {type: integer}}
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  things: {type: array, items: {type: string}}

Good

parameters:
  - {name: limit, in: query, schema: {type: integer}}
  - {name: start, in: query, schema: {type: string}}

Known false positives and limitations

Datasets that are static and indexed, where offsets are cheap and stable, are flagged anyway. An offset parameter on an operation that is not recognised as a paginated list (no array property in the first success response, or a path ending in a parameter) is not reported. Only local references are followed.

func PropertyNameCollisionAfterNormalising

func PropertyNameCollisionAfterNormalising() Rule

PropertyNameCollisionAfterNormalising returns the extra-property-name-collision-after-normalising rule.

What it checks

Within one schema no two property names may become identical once the case convention is ignored. Names are normalised by lower-casing them and removing underscores, hyphens, dots and spaces, so thingType, thing_type, thing-type and ThingType all collide. Such pairs are distinct in JSON but collapse to one member in generated code or in clients that convert case, silently dropping data. Every property after the first of a colliding group is reported at its own key.

Where it comes from

IBM's openapi-validator (ibm-property-case-collision).

Options

None.

Bad

components:
  schemas:
    Thing:
      type: object
      properties:
        thingType: {type: string}
        thing_type: {type: string}

Good

components:
  schemas:
    Thing:
      type: object
      properties:
        thingType: {type: string}
        thingKind: {type: string}

Known false positives

Names that differ only in case or separators on purpose (for example a pair of legacy and current spellings kept for compatibility) are flagged. Only the properties declared directly in one schema are compared, not those merged from allOf members.

func PutBodyMatchesGetResponse

func PutBodyMatchesGetResponse() Rule

PutBodyMatchesGetResponse returns the extra-put-body-matches-get-response rule.

What it checks

When a path item has both a get and a put operation, the schema of each put request body media type must be equal to the schema of the same media type in the get success response. The default response is the 200 response. Schemas are compared structurally after local $refs are followed, so a $ref and the inlined schema it points to are equal; description, title and example keywords are ignored. A put media type that the get response does not offer is not compared, and neither is a path without both operations.

Why

PUT replaces the representation that GET returns. When the two schemas drift apart, clients cannot read a resource, change a field and write it back, and the API stops being round-trippable.

Where it comes from

openapilint (operation-payload-put), which enforces that the PUT payload matches the GET 200 response.

Options

  • responseCode (string, default "200"): the get response whose schema the put body must match.

Bad

paths:
  /pets/{id}:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema: {$ref: "#/components/schemas/Pet"}
    put:
      requestBody:
        content:
          application/json:
            schema: {$ref: "#/components/schemas/NewPet"}

Good

schema: {$ref: "#/components/schemas/Pet"}

Known false positives and limitations

Resources whose read model contains server-generated fields (ids, timestamps) legitimately differ from the write model; configure a different response code or suppress the rule for them. Equality is exact: reordering of allOf members or required entries counts as a difference.

func QueryArrayStyleForm

func QueryArrayStyleForm() Rule

QueryArrayStyleForm returns the extra-query-array-style-form rule.

What it checks

In OpenAPI 3 documents, a query parameter whose schema is an array must set style: form explicitly. A parameter with a different style, or with no style at all, is reported. Parameters are read from operations, path items and components.parameters, and $ref schemas are followed.

Why

form is the default style of query parameters, but relying on the default hides an important choice: together with explode it decides whether the query string reads tags=a&tags=b or tags=a,b. Writing the style down avoids tool disagreements and keeps the intent visible to reviewers.

Where it comes from

Zally rule 154, "Use and Specify Explicitly the Form-Style Query Format for Collection Parameters" (QueryParameterCollectionFormatRule, severity SHOULD). Like the original it examines components.parameters, path item parameters and operation parameters of OpenAPI 3 documents, selects those with in: query and a schema of type array, and reports a missing style or any style other than form.

Options

None.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: tags
          in: query
          schema:
            type: array
            items:
              type: string

Good

paths:
  /pets:
    get:
      parameters:
        - name: tags
          in: query
          style: form
          schema:
            type: array
            items:
              type: string

Known false positives / limitations

APIs that purposely use spaceDelimited, pipeDelimited or deepObject for arrays are reported. Parameters described with content instead of schema are ignored. OpenAPI 2.0 documents are not checked.

func QueryParamWireKeyCollision

func QueryParamWireKeyCollision() Rule

QueryParamWireKeyCollision returns the extra-query-param-wire-key-collision rule.

What it checks

Query parameters of one operation are serialised to wire keys. A plain parameter produces one key, its own name. An object parameter with style form and explode true (the defaults) produces one key per property of the object. A deepObject parameter produces name[property] keys. When two parameters of an operation produce the same key, their schemas must be compatible, which means that they declare the same type and format. Incompatible collisions are reported at the parameter that comes later.

Why

On the wire, the server only sees key=value pairs. If an exploded object property and another parameter share a key but disagree on the type, the server cannot know which definition to apply to the value, so validation and generated clients behave unpredictably.

Where it comes from

Specmatic (query parameters serialising to the same wire key).

Options

None.

Bad

paths:
  /search:
    get:
      parameters:
        - name: color
          in: query
          schema:
            type: string
        - name: filter
          in: query
          schema:
            type: object
            properties:
              color:
                type: integer

Good

paths:
  /search:
    get:
      parameters:
        - name: color
          in: query
          schema:
            type: string
        - name: filter
          in: query
          schema:
            type: object
            properties:
              size:
                type: integer

Known false positives / limitations

Array, spaceDelimited and pipeDelimited serialisation produce the parameter name as the key and are handled as plain parameters. Compatibility compares only type and format of $ref-resolved schemas, not constraints.

func ReadonlyAndWriteonlyExclusive

func ReadonlyAndWriteonlyExclusive() Rule

ReadonlyAndWriteonlyExclusive returns the extra-readonly-and-writeonly-exclusive rule.

What it checks

A schema must not set both readOnly and writeOnly to true. The two keywords are mutually exclusive: a read-only property is only sent by the server and a write-only property is only sent by the client, so a property that is both can never appear in any message.

Where it comes from

KaiZen OpenAPI Parser, which reports a property that is both readOnly and writeOnly.

Options

None.

Bad

components:
  schemas:
    User:
      type: object
      properties:
        password:
          type: string
          readOnly: true
          writeOnly: true

Good

components:
  schemas:
    User:
      type: object
      properties:
        password:
          type: string
          writeOnly: true

Known false positives

None known. Only the literal value true is considered; a keyword set to false is never reported.

func RefPatternComponentLocation

func RefPatternComponentLocation() Rule

RefPatternComponentLocation returns the extra-ref-pattern-component-location rule.

What it checks

A port of IBM's ibm-ref-pattern. Every $ref whose value is a string that starts with # is checked against the location of the object that holds it. The location (the keys and array indexes from the document root to the holder, joined with commas) decides which kind of object is expected, and the value must start with the matching prefix. The patterns are tried in this order and the first one that matches decides:

  • schemas: the holder is a schema, properties,<name>, items, additionalProperties or an allOf, anyOf or oneOf entry; the prefix is #/components/schemas/;
  • parameters: holder at parameters,<index>; #/components/parameters/;
  • responses: holder at responses,<code>; #/components/responses/;
  • requestBodies: holder at requestBody; #/components/requestBodies/;
  • links: holder at links,<name>; #/components/links/;
  • examples: holder at examples,<name> (media types, parameters and components alike); #/components/examples/;
  • headers: holder at headers,<name>; #/components/headers/;
  • securitySchemes: holder at securitySchemes,<name>; #/components/securitySchemes/;
  • callbacks: holder at callbacks,<name>; #/components/callbacks/.

The message is "$refs to <kind> should start with '<prefix>'" and the finding is placed on the $ref. Only the prefix is compared, like in IBM's rule, so a reference such as #/components/schemas/Pet/properties/name is accepted. A $ref that is not a string (a property named $ref) and a $ref to another file or URL are not inspected. Every $ref in the document is visited, including the ones that sit in example values and vendor extensions, as IBM's $..$ref does.

Why

Pointing a schema at #/paths/~1pets/get/responses/200/content/... works for a resolver but defeats reuse, breaks bundlers and makes generators invent unstable names. Components are the supported place for reusable objects.

Where it comes from

IBM's openapi-validator (ibm-ref-pattern, severity warn).

Options

None.

Bad

parameters:
  - $ref: "#/components/schemas/PetId"

Good

parameters:
  - $ref: "#/components/parameters/PetId"

Known false positives and limitations

A $ref held by a path item, a security requirement or other objects that the patterns do not list is not checked, as in the original. Keys that contain a comma can confuse the location patterns, as in the original.

func RefSiblingDescriptionNotDuplicate

func RefSiblingDescriptionNotDuplicate() Rule

RefSiblingDescriptionNotDuplicate returns the extra-ref-sibling-description-not-duplicate rule.

What it checks

A description written next to a reference is meant to override the description of the referenced schema for that one use. When it is exactly the same text (compared after collapsing white space) it overrides nothing and only repeats what the target already says. Two shapes are recognised: the OpenAPI 3.1 sibling form, a schema with $ref and description side by side, and the allOf form used for OpenAPI 3.0, a schema whose allOf list holds a single $ref member and a description of its own. The reference must be local and resolvable, and the target must have a description.

Where it comes from

IBM's openapi-validator, whose ref-sibling rules reject descriptions that duplicate the one of the referenced schema.

Options

None.

Bad

components:
  schemas:
    Name:
      type: string
      description: The name of the pet.
    Pet:
      type: object
      properties:
        name:
          description: The name of the pet.
          allOf:
            - $ref: "#/components/schemas/Name"

Good

name:
  description: The name that the owner chose for the pet.
  allOf:
    - $ref: "#/components/schemas/Name"

Known false positives

External references cannot be followed and are not checked. A duplicated description is occasionally left on purpose so that it survives later edits of the target; the rule still reports it.

func RequestBodyJSONMediaType

func RequestBodyJSONMediaType() Rule

RequestBodyJSONMediaType returns the extra-request-body-json-media-type rule.

What it checks

An operation whose request body defines a non-empty content map must include the configured media type, application/json by default, as an exact key. A key such as application/json; charset=utf-8, application/vnd.api+json or application/*+json does not count. A request body given by $ref is judged by the object it points at, and operations without a request body, or with an empty content map, are not reported.

Why

Language-model agents, code generators and most HTTP tooling default to JSON. A request body offered only as XML, form data or a vendor type cannot be called by a client that has only the plain JSON media type available.

Where it comes from

ai-api-lint (request body should support application/json).

Options

  • mediaType (string, default "application/json"): the media type that has to be offered.

Bad

paths:
  /pets:
    post:
      requestBody:
        content:
          application/xml:
            schema: {type: string}

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema: {type: string}
          application/xml:
            schema: {type: string}

Known false positives and limitations

File upload operations that only accept multipart/form-data or application/octet-stream are reported, since they cannot offer JSON; suppress the rule for them. An empty mediaType option disables the rule.

func RequestBodyRequiredList

func RequestBodyRequiredList() Rule

RequestBodyRequiredList returns the extra-request-body-required-list rule.

What it checks

For every operation, the schema of the JSON request body must list its mandatory properties. A schema that declares properties but has no required list, or an empty one, is reported. The schema is read from the media types named by the mediaTypes option, and a $ref schema is followed to its target.

Why

Without a required list every property is optional. Clients, code generators and AI agents then cannot tell which fields they must send, and servers receive incomplete payloads that only fail at runtime.

Where it comes from

ai-api-lint (AI032, request body schema should specify required fields).

Options

  • mediaTypes: the request body media types to inspect. Default: application/json.

Bad

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name: {type: string}

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name: {type: string}

Known false positives / limitations

Request bodies in which every property is genuinely optional, such as PATCH payloads, are reported. Only the top-level schema is examined; properties introduced through allOf are not counted.

func RequestBodySchemaHasProperties

func RequestBodySchemaHasProperties() Rule

RequestBodySchemaHasProperties returns the extra-request-body-schema-has-properties rule.

What it checks

The schema of a JSON request body (media type application/json or any +json type) must describe its properties. The schema is $ref-resolved first. An object schema (or one without a type) that has no properties and none of allOf, anyOf, oneOf, additionalProperties or patternProperties is reported, because it describes nothing about the payload. Schemas of another type, such as arrays or strings, are not reported.

Why

A body that is declared as a bare object tells consumers and code generators nothing: clients cannot construct it, validators accept anything, and language models that read the specification have no field names to use.

Where it comes from

ai-api-lint (request-body-schema-has-properties).

Options

None.

Bad

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string

Known false positives / limitations

A deliberately free-form body is not reported when it declares additionalProperties; one that declares nothing at all is. Request bodies declared in components.requestBodies are checked where they are defined.

func RequestResponseMustBeModels

func RequestResponseMustBeModels() Rule

RequestResponseMustBeModels returns the extra-request-response-must-be-models rule.

What it checks

Every request body schema and every response body schema whose media type uses a JSON representation (application/json, application/json-patch+json and application/merge-patch+json, each optionally followed by parameters) and whose schema is an object schema must define at least one static property. Schemas are followed through local $ref.

A schema is an object schema when it, or a schema composed into it, has type object (alone or in a type array), or has no type but defines properties, patternProperties, or an additionalProperties that is true or a schema. The composition semantics are the ones IBM uses everywhere: a predicate holds for a schema when the schema itself satisfies it, or when any allOf member satisfies it, or when all members of a non-empty oneOf satisfy it, or when all members of a non-empty anyOf satisfy it. The schema "defines properties" under the same composition semantics when a properties map has at least one entry.

Schemas that are not object schemas (arrays, primitives) are deliberately not reported by this rule, exactly like the original: other rules of the family cover them. A body that is a dictionary (additionalProperties only) is an object schema without properties and is reported.

Why

Models can evolve by adding properties without breaking clients, and SDK generators produce a named type for them. A dictionary or an empty object cannot be turned into a typed model.

Where it comes from

IBM openapi-validator, ibm-accept-and-return-models (Request and response bodies must be models - their schemas must define properties). The original depends on its sibling rules to catch non-object bodies; so does this one.

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: string

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  pets:
                    type: array
                    items:
                      type: string

Known false positives and limitations

Only local references are followed, so a body whose schema is an external $ref is not analysed. The finding is placed on the schema as written in the operation, whereas the original reports the resolved location.

func RequiredParametersBeforeOptional

func RequiredParametersBeforeOptional() Rule

RequiredParametersBeforeOptional returns the extra-required-parameters-before-optional rule.

What it checks

In the parameters list of an operation, every required parameter must be listed before every optional one. Each required parameter that follows an optional parameter is reported on its own entry. $ref entries are resolved to decide whether they are required. Only the parameters declared on the operation itself are compared, not those inherited from the path item.

Why

Code generators that turn parameters into positional function arguments cannot place a required argument after an optional one in most languages, so they reorder the parameters and break the signature whenever the order changes. A stable order of required first avoids that.

Where it comes from

IBM's API Handbook ruleset (ibm-parameter-order).

Options

None.

Bad

parameters:
  - {name: limit, in: query, schema: {type: integer}}
  - {name: id, in: path, required: true, schema: {type: string}}

Good

parameters:
  - {name: id, in: path, required: true, schema: {type: string}}
  - {name: limit, in: query, schema: {type: integer}}

Known false positives

None known. Path parameters are required by definition but are only treated as required when they say so with required: true.

func RequiredStringMinLength

func RequiredStringMinLength() Rule

RequiredStringMinLength returns the extra-required-string-min-length rule.

What it checks

A property that is listed in the required array of its object schema and whose own schema is a string must declare minLength. Without a lower bound a required string may be empty, which satisfies the schema while carrying no information, and clients tend to send "" for values they do not have. The property schema is followed through a local $ref. Strings that are enums or constants, strings whose format never yields an empty value and already shapes it (see the shapedFormats option), and 3.1 type lists that do not include string, are skipped.

Where it comes from

Redocly CLI (rule requiring minLength for required string properties).

Options

  • shapedFormats (list of strings): the formats that satisfy the minLength demand. Default: date, date-time, time, duration, uuid, uri, uri-reference, iri, url, email, idn-email, hostname, idn-hostname, ipv4, ipv6, json-pointer, regex, byte. Set it to an empty list to require minLength on every string.

Bad

components:
  schemas:
    Pet:
      type: object
      required: [name]
      properties:
        name:
          type: string

Good

components:
  schemas:
    Pet:
      type: object
      required: [name]
      properties:
        name:
          type: string
          minLength: 1

Known false positives

A required string that is legitimately allowed to be empty is flagged; set minLength: 0 to state that explicitly. Required properties declared only in an allOf member of another schema are not matched with the properties of this schema.

func ReservedHeaderParameter

func ReservedHeaderParameter() Rule

ReservedHeaderParameter returns the extra-reserved-header-parameter rule.

What it checks

A parameter with in: header must not be named after a header that OpenAPI reserves. The names are compared case-insensitively and default to Accept, Content-Type and Authorization. Parameters are looked at on path items, on operations and under components.parameters. A response header named Content-Type is flagged too, since OpenAPI ignores it as well.

Why

The OpenAPI specification says that header parameters named Accept, Content-Type or Authorization SHALL be ignored, and that a Content-Type response header SHALL be ignored. These headers are controlled by the requestBody and response content keys (Content-Type, Accept) and by security schemes (Authorization). Declaring them as parameters is misleading: some tools honour the declaration and override the media type, others silently drop it, so the contract and the generated client disagree.

Where it comes from

specmatic (it overrides the media type from a Content-Type header parameter and warns when Accept header values cannot match the response content types). This rule reports the declaration itself and, in addition, the two situations specmatic warns about (the overridden media type and the Accept header that does not allow a response content type).

Options

  • names (list of strings, default Accept, Content-Type, Authorization): the reserved header names.

Bad

paths:
  /pets:
    post:
      parameters:
        - name: Content-Type
          in: header
          schema: {type: string}

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema: {type: object}

Known false positives and limitations

Authorization is reserved by the specification but widely declared by documents whose security scheme cannot express their token; remove it from names to allow it. Parameters given by $ref are checked where they are declared in components.parameters. Accept and Content-Type values are only known for enum and const schemas, as in specmatic; a header schema that is a free string is never compared. The Accept and Content-Type compatibility checks apply even when the names option does not list those headers.

func ResourceResponseConsistency

func ResourceResponseConsistency() Rule

ResourceResponseConsistency returns the extra-resource-response-consistency rule.

What it checks

A port of the IBM function resourceResponseConsistency. It examines POST, PUT and PATCH operations. A POST is only examined when it is a create operation: its operationId (trimmed, case-insensitive) starts with "create", or a sibling path of the form {path}/{param} exists (POST /things next to /things/{id}).

The expected ("canonical") schema is the JSON schema of the GET operation on the resource: for a POST the GET of the sibling instance path, for PUT and PATCH the GET of the same path. That schema is the one of the 200 response when the GET has one, otherwise of the first 2xx response with a JSON schema, taken from the first application/json media type (optionally with parameters). Only the media types that are exactly application/json count.

Every JSON media type of the 200 and 201 responses of the examined operation that defines a schema must have a schema deeply equal to the canonical one after $ref resolution (key order is irrelevant, array order is not). The finding is reported on the media type object, for example paths['/things'].post.responses['201'].content['application/json'].

A PUT on a path whose GET returns a $ref schema named *Collection is a bulk operation and gets the message "Bulk resource operations should return the resource collection schema: Name"; everything else gets "Operations on a single resource instance should return the resource canonical schema" with ": Name" appended when the GET schema is a $ref to a named schema. When the GET has no JSON schema, the operation has no 2xx or 200/201 JSON response, or there is no sibling path for a POST, nothing is reported.

Why

A client that creates or updates a resource expects to receive the representation it would get when reading it. Diverging schemas force clients to model the same resource twice and are a common source of generator bugs.

Where it comes from

IBM openapi-validator (ibm-resource-response-consistency).

Options

None.

Bad

paths:
  /things:
    post:
      responses:
        "201":
          content:
            application/json:
              schema: {$ref: "#/components/schemas/ThingSummary"}
  /things/{id}:
    get:
      responses:
        "200":
          content:
            application/json:
              schema: {$ref: "#/components/schemas/Thing"}

Good

paths:
  /things:
    post:
      responses:
        "201":
          content:
            application/json:
              schema: {$ref: "#/components/schemas/Thing"}
  /things/{id}:
    get:
      responses:
        "200":
          content:
            application/json:
              schema: {$ref: "#/components/schemas/Thing"}

Known false positives / limitations

The comparison is structural and exact, as in IBM: two schemas that describe the same data in different ways are reported. Only local $ref values are resolved, and the schema name in the message is the last segment of the $ref held directly by the GET media type.

func ResourceSchemaNamingConvention

func ResourceSchemaNamingConvention() Rule

ResourceSchemaNamingConvention returns the extra-resource-schema-naming-convention rule.

What it checks

A port of IBM's ibm-schema-naming-convention. For every pair of resource-oriented paths, a collection path (one that does not end in a path variable, such as /pets) and its first sibling instance path (/pets/{pet_id}: the collection path followed by one {variable} segment), the schema names must derive from the canonical schema. The canonical schema is the JSON schema of the success response of GET on the instance path (code 200 when present, else the first 2xx code with a JSON schema; the first application/json media type, parameters allowed). Its name is the component name the schema references; an inline schema has no name and the checks that need it are skipped. For a canonical name Pet:

  • the success response schema of GET on the collection path must be named PetCollection ("Collection schema for path '/pets' should use the name: PetCollection");
  • when that schema has a property named after the last segment of the collection path (found directly, in allOf, or in every oneOf and anyOf member), the schema of its items must be named Pet or PetSummary;
  • the application/json request body schema of POST on the collection path and of PUT on the instance path must be named PetPrototype or Pet;
  • the application/json-patch+json or application/merge-patch+json request body schema of PATCH on the instance path must be named PetPatch.

Findings sit on the schema of the media type, or on the items of the list property, and use IBM's messages.

Why

Predictable names let consumers and generated SDKs find the schema that belongs to an operation: a client can derive PetCollection, PetPrototype and PetPatch from Pet without reading the document.

Where it comes from

IBM's openapi-validator (ibm-schema-naming-convention, severity warn).

Options

None.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PetList"
  /pets/{pet_id}:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"

Good

The same document with the collection response referencing "#/components/schemas/PetCollection".

Known false positives and limitations

As in the original, the relation between the canonical schema name and the path segments (pluralisation) and the names of identity or reference schemas are not checked. A schema name is read from the $ref found at the schema position; chains of references are not followed.

func ResponseContainsHeader

func ResponseContainsHeader() Rule

ResponseContainsHeader returns the extra-response-contains-header rule.

What it checks

The responses of every operation must declare the configured headers. The headers option maps a response code to the list of header names that the response must define in its headers object. A configured key matches a response whose code is the same (compared case-insensitively, so default and 4XX work), and a range key such as 4XX also matches every response whose code starts with that digit, for example 404. Header names are compared case-insensitively. Responses defined through a local $ref are resolved.

The rule does nothing when the headers option is empty, which is its default.

Declaring headers such as rate-limit counters or a request id in the contract lets clients depend on them.

Where it comes from

Redocly CLI, rule response-contains-header, which is configured with a map of response codes to header names.

Options

  • headers (map of response code to list of header names, no default): the headers that responses must declare, for example {"200": ["X-Request-Id"], "4XX": ["Retry-After"]}.

Bad

With headers set to {"200": ["X-Request-Id"]}:

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          headers:
            X-Request-Id:
              schema:
                type: string

Known false positives

A response that is required by one key and satisfied by another (for example 404 matched by both 404 and 4XX) must declare the union of the headers of every matching key. The Content-Type header is not a response header in OpenAPI and cannot be required.

func ResponseContainsProperty

func ResponseContainsProperty() Rule

ResponseContainsProperty returns the extra-response-contains-property rule.

What it checks

A port of Redocly CLI's response-contains-property. For every response except 204, the schema of every media type must define the properties that the names option lists for the status code. The lookup is the one Redocly uses: the exact code (200), else its range (2XX), else the lower-case range (2xx); the first key present wins, and default is looked up as itself.

Redocly only inspects a schema whose type is object. This port does the same, and additionally inspects a schema that declares no type at all but composes objects (properties, allOf, oneOf or anyOf), which is how most response envelopes are written. Properties are collected from the schema itself, from every allOf member (any member may supply the property) and from oneOf and anyOf (the property must be present in every branch, because a response matching a branch without it would lack the property). Local $refs are followed. A schema that declares a type other than object (an array, a string) is skipped, as in Redocly.

The finding is placed on the properties keyword of the media type schema (JSONPath .schema.properties), like Redocly's location.child('properties'), and says that the response must contain a top-level property.

Where it comes from

Redocly CLI, rule response-contains-property (packages/core/src/rules/oas3 and oas2, option names).

Options

  • names (map of status code or range to a list of property names, no default): for example {"4XX": ["message"], "200": ["id"]}. When the map is empty the rule does nothing.

Bad

# names: {"4XX": ["message"]}
responses:
  "404":
    description: Not found
    content:
      application/json:
        schema:
          type: object
          properties:
            code: {type: integer}

Good

responses:
  "404":
    description: Not found
    content:
      application/json:
        schema:
          type: object
          properties:
            message: {type: string}

Known false positives and limitations

When the schema is a $ref the finding is reported at the referencing media type rather than inside the component, because no resolved-document location is available. Properties that only exist in a oneOf or anyOf branch are not counted (by design, see above). Only top-level properties are checked, as in Redocly.

func ResponseRequestContentRequired

func ResponseRequestContentRequired() Rule

ResponseRequestContentRequired returns the extra-response-request-content-required rule.

What it checks

Every request body and every response of an operation must have a content map. A response without content cannot be validated or deserialized by clients, and a request body without content gives the server nothing to parse. The check follows local $ref references, so a response shared in components is checked in the context of the status code that uses it. Responses that by definition carry no body are exempt: 204 and 304 (the ignoreCodes option), any 1xx informational code, and every response of a HEAD operation.

Where it comes from

IBM's openapi-validator (ibm-request-and-response-content), which requires content on request bodies and on responses other than 204.

Options

  • ignoreCodes: status codes exempt from the check. Default: 204, 304.

Bad

paths:
  /pets:
    post:
      requestBody:
        description: a pet
      responses:
        "201":
          description: created

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        "201":
          description: created
          content:
            application/json:
              schema:
                type: object

Known false positives

Error responses such as 404 that intentionally return an empty body are flagged; add their codes to ignoreCodes or document an error body.

func ResponseRequiredProperties

func ResponseRequiredProperties() Rule

ResponseRequiredProperties returns the extra-response-required-properties rule.

What it checks

In the JSON response schemas of operations, and in components.responses, every property that is an array, and every property that is an enumeration (it has an enum), must be listed in the required list of the object that declares it. The check descends through nested objects, array items, additionalProperties and the allOf, anyOf and oneOf members, following local $refs. A property is also considered required when a sibling allOf member requires it.

Why

A response should never leave a client guessing. An absent array forces every consumer to distinguish between "not sent" and "empty", and an absent enumeration value forces handling of a state the server never intends to produce. Returning an empty list and always returning the enumeration makes responses simpler to consume.

Where it comes from

IBM openapi-validator, merging ibm-required-array-properties-in-response and ibm-required-enum-properties-in-response.

Options

  • arrays (bool, default true): require array properties.
  • enums (bool, default true): require enumeration properties.

Bad

components:
  schemas:
    ThingCollection:
      type: object
      properties:
        things:
          type: array
          items: {type: string}
        status:
          type: string
          enum: [on, off]

Good

components:
  schemas:
    ThingCollection:
      type: object
      required: [things, status]
      properties:
        things:
          type: array
          items: {type: string}
        status:
          type: string
          enum: [on, off]

Known false positives and limitations

Only schemas reachable from a response are examined, but the finding points at the property where it is declared, which may be in components.schemas and shared with request bodies. Properties declared read-only or write-only are not treated specially.

func ResponseStatusCodeSemantics

func ResponseStatusCodeSemantics() Rule

ResponseStatusCodeSemantics returns the extra-response-status-code-semantics rule.

What it checks

A port of the IBM function responseStatusCodes. Operations with a responses object that has at least one three-digit status code (1xx to 5xx; keys such as default or 2XX are not status codes for this rule) are checked as follows:

  • 422 is discouraged, use 400 for invalid request payloads (reported on the 422 response).
  • 302 is discouraged, use 303 or 307 (reported on the 302 response).
  • At least one success (2xx) code must be present, unless 101 is (reported on responses).
  • 101 must not be combined with success codes (reported on the 101 response).
  • A 204 response must not have content (reported on its content).
  • A create operation must return 201 or 202. A create is an operation whose operationId starts with "create" (trimmed, case-insensitive), or a POST on a collection path that has a sibling {path}/{param} path. A 204 is accepted instead only when the create returns 204 and the resource has no body representation: there is no sibling path, or the GET on the sibling path has no 204 response. IBM reports this even when the operation has no success code at all.
  • PUT must return 200, 201 or 202, or 204 when the GET on the same path itself declares a 204 response (a minimally represented resource).
  • PATCH must return 200 or 202.
  • 202 must not be combined with other 2xx codes.
  • 301, 302, 305 and 307 responses must have content (reported on responses, once per offending code).

Messages are the IBM messages. $ref values on responses are resolved.

Why

Clients branch on status codes. A 204 with a body, a create answered with 200 or a redirect without a target description each break an assumption that generic clients, caches and gateways make.

Where it comes from

IBM openapi-validator (ibm-response-status-codes).

Options

None.

Bad

paths:
  /things:
    post:
      operationId: createThing
      responses:
        "200":
          description: ok
        "422":
          description: invalid

Good

paths:
  /things:
    post:
      operationId: createThing
      responses:
        "201":
          description: created
        "400":
          description: invalid

Known false positives / limitations

The rule ports IBM literally, including the exceptions above: the minimal representation test only looks for a 204 key on the relevant GET operation. Range keys such as 3XX are not examined.

func SSRFParameterName

func SSRFParameterName() Rule

SSRFParameterName returns the extra-ssrf-parameter-name rule.

What it checks

The name of every parameter declared directly on a path item or on an operation (not in components, and not through a $ref) must not match the pattern. By default the pattern matches the names callback and redirect and every name that ends with _url, -url or Url (return_url, callback-url, imageUrl). Matching is case-sensitive and, because the end anchor applies to the whole group, a name that merely starts with callback (callbackHandler) does not match. Matching parameters are reported.

Parameters that make the server fetch or redirect to a caller-supplied URL are the entry point of server-side request forgery and open-redirect attacks. The rule points the reviewer at them so that the input is validated against an allow-list.

Where it comes from

The Spectral OWASP ruleset, rule owasp:api7:2023-concerning-url-parameter, which runs given $.paths[*].parameters[*].name and $.paths[*][get,put,post,delete,options,head,patch,trace].parameters[*].name with the pattern function (notMatch) and information severity.

Options

  • pattern (string, default (^(callback|redirect)|(_url|Url|-url))$): regular expression a parameter name must not match. An empty string disables the rule, and a pattern that is not a valid regular expression disables it too.

Bad

paths:
  /fetch:
    get:
      parameters:
        - name: callback_url
          in: query
          schema:
            type: string

Good

paths:
  /fetch:
    get:
      parameters:
        - name: resourceId
          in: query
          schema:
            type: string

Known false positives

Parameters under components.parameters and parameters given as a $ref are not inspected, as in the original. A parameter that is a URL by design (a webhook registration, for example) is reported even when the server validates it. The rule is a prompt to review such inputs, so suppress it for the parameters that are reviewed.

func SchemaDescriptionRequired

func SchemaDescriptionRequired() Rule

SchemaDescriptionRequired returns the extra-schema-description-required rule.

What it checks

Every schema must have a non-empty description. A schema that is a bare $ref is not checked (its target is), and a schema counts as described when any member of its allOf, anyOf or oneOf lists (followed through local $ref) has a description. With scope set to "components" only the top-level schemas under components.schemas are checked.

Why

Descriptions are the documentation of the data model. Generated reference pages and client libraries show them, and a schema without one leaves its meaning to be guessed.

Where it comes from

The IBM API Handbook ruleset (ibm-schema-description-exists).

Options

  • scope (string, default "all"): "all" checks every schema including properties and items, "components" checks component schemas only.

Bad

components:
  schemas:
    Pet:
      type: object

Good

components:
  schemas:
    Pet:
      type: object
      description: A pet in the store.

Known false positives / limitations

With scope "all" every property schema needs a description, which is noisy for self-explanatory fields. Schemas that only wrap another schema with allOf and carry no description of their own are accepted only when a member has one.

func SchemaKeywordTypeConsistency

func SchemaKeywordTypeConsistency() Rule

SchemaKeywordTypeConsistency returns the extra-schema-keyword-type-consistency rule.

What it checks

The validation keywords of a schema must be consistent with its type and with each other. Two kinds of problems are reported:

  • A lower bound greater than its upper bound: minimum and maximum, minLength and maxLength, minItems and maxItems, minProperties and maxProperties, minContains and maxContains. The numeric exclusive forms (OpenAPI 3.1) are compared strictly: exclusiveMinimum must be below maximum and exclusiveMaximum, and minimum must be below exclusiveMaximum. In the OpenAPI 3.0 boolean form, exclusiveMinimum or exclusiveMaximum set to true is reported when minimum equals maximum, because the range is then empty.
  • A keyword that does not apply to the declared type: minimum, maximum, exclusiveMinimum, exclusiveMaximum and multipleOf need integer or number; minLength, maxLength and pattern need string; minItems, maxItems, uniqueItems, items, prefixItems, contains, minContains, maxContains and unevaluatedItems need array; properties, additionalProperties, patternProperties, propertyNames, unevaluatedProperties, minProperties, maxProperties and required (as a list) need object.

Schemas without a declared type are not checked for the second kind of problem. A type list in OpenAPI 3.1 allows a keyword when any of its entries does.

Such schemas are almost always mistakes, and the keywords are silently ignored by validators, so the intended constraint is never enforced.

Where it comes from

IBM openapi-validator, rule ibm-schema-type-format and the related schema consistency checks, which relate numeric, string, array and object keywords to the schema type.

Options

None.

Bad

components:
  schemas:
    Age:
      type: string
      minimum: 0

Good

components:
  schemas:
    Age:
      type: integer
      minimum: 0

Known false positives

Only keywords declared directly on the schema are inspected, so a keyword that is valid through an allOf member is not seen, and the type of an untyped schema is not inferred from its allOf members.

func SchemaPropertyDescription

func SchemaPropertyDescription() Rule

SchemaPropertyDescription returns the extra-schema-property-description rule.

What it checks

Every property of every schema must have a description that is not empty and not just whitespace. A property written as a $ref satisfies the rule when its own node or the referenced schema has a description. The finding is reported on the property.

Why

Property names alone rarely explain units, formats, nullability or intent. Generated reference documentation and SDK comments are only as good as the descriptions they are built from.

Where it comes from

IBM's API Handbook ruleset (ibm-schema-description / property description requirement).

Options

None.

Bad

Pet:
  type: object
  properties:
    name:
      type: string

Good

Pet:
  type: object
  properties:
    name:
      type: string
      description: The display name of the pet.

Known false positives

Properties that are composed with allOf and take their description from a branch are reported, because only the property itself and its direct $ref target are inspected.

func SchemaTypeFormatWhitelist

func SchemaTypeFormatWhitelist() Rule

SchemaTypeFormatWhitelist returns the extra-schema-type-format-whitelist rule.

What it checks

The type of a schema must be one of the JSON Schema primitive types and its format must be known for that type. Defaults: types array, boolean, integer, number, object, string (plus null in OpenAPI 3.1 type lists); integer formats int32 and int64; number formats float and double (and the integer formats, because numbers may be integral); string formats byte, binary, date, date-time, password, email, uuid, uri, url, hostname, ipv4 and ipv6. A format is only checked when the schema has exactly one non-null type, and the boolean, array and object types accept no format at all. Unknown types such as int or float, and formats such as int128 or datetime, are the typical typos this rule catches.

Where it comes from

IBM's openapi-validator (ibm-schema-type-format).

Options

  • types: allowed type names. Default: array, boolean, integer, number, object, string, null.
  • integerFormats: allowed integer formats. Default: int32, int64.
  • numberFormats: allowed number formats. Default: float, double, int32, int64.
  • stringFormats: allowed string formats (the JSON Schema 2020-12 formats duration, time, uri-reference, iri and the like are included). Default: byte, binary, date, date-time, password, email, uuid, uri, url, hostname, ipv4, ipv6.

Bad

components:
  schemas:
    Count:
      type: int
    When:
      type: string
      format: datetime

Good

components:
  schemas:
    Count:
      type: integer
      format: int64
    When:
      type: string
      format: date-time

Known false positives

Custom formats that are legal in OpenAPI (for example format: money) are flagged unless they are added to the matching option.

func SchemaTypeKeywordMismatch

func SchemaTypeKeywordMismatch() Rule

SchemaTypeKeywordMismatch returns the extra-schema-type-keyword-mismatch rule.

What it checks

A schema must not carry keywords that belong to a type it does not have:

  • a schema with a declared type other than array must not carry items;
  • a schema with a declared type other than object must not carry properties;
  • with requireExplicitType (the default), a schema that carries properties but declares no type must declare type: object, and one that carries items but declares no type must declare type: array.

OpenAPI 3.1 type arrays are honoured: ["object", "null"] allows properties.

Why

JSON Schema ignores keywords that do not apply to the instance type, so an items keyword on a string schema silently does nothing. These are almost always copy and paste mistakes, and tools disagree on how to treat them. Leaving the type out of a schema with properties makes generators fall back to an untyped value instead of an object.

Where it comes from

Merges Redocly CLI (schema-type-keyword-mismatch) with oas-kit (schema-with-properties-must-be-type-object).

Options

  • requireExplicitType (bool, default true): also require type: object next to properties and type: array next to items. With false only an explicit, contradicting type is reported.

Bad

components:
  schemas:
    Tag:
      type: string
      items:
        type: string
    Pet:
      properties:
        name: {type: string}

Good

components:
  schemas:
    Tag:
      type: array
      items:
        type: string
    Pet:
      type: object
      properties:
        name: {type: string}

Known false positives and limitations

Schemas that are valid JSON Schema without a type (for instance allOf wrappers that add properties) are reported while requireExplicitType is on. The same applies to a type given only in an allOf member.

func SecurityScopesDeclared

func SecurityScopesDeclared() Rule

SecurityScopesDeclared returns the extra-security-scopes-declared rule.

What it checks

Three checks on the security of the API, for OpenAPI 3 documents:

  • components.securitySchemes must contain at least one allowed scheme.
  • Every scheme must be of an allowed kind. By default these are oauth2 and HTTP bearer authentication; any other type (apiKey, basic, openIdConnect, mutualTLS) is reported.
  • Every scope listed in a security requirement, at the document level or in an operation, must be declared in a flow of the referenced OAuth2 scheme.

Why

Scopes are what lets a token be limited to the operations it needs. A scope that is used but never declared cannot be requested by clients, so the operation is effectively unusable or is protected by nothing. Restricting the scheme types keeps the API on token based authentication.

Where it comes from

Zally (SecureAllEndpointsRule: secure endpoints with OAuth2 or Bearer authentication, and used scopes must be specified in the security definition).

Options

  • allowedTypes: the allowed scheme kinds. Use oauth2 for OAuth2 and bearer for HTTP bearer authentication; any other value is matched against the type of the scheme. Default: oauth2, bearer.

Bad

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://auth.example.com/token
          scopes:
            pets.read: read pets
paths:
  /pets:
    get:
      security:
        - oauth: [pets.write]

Good

components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://auth.example.com/token
          scopes:
            pets.read: read pets
paths:
  /pets:
    get:
      security:
        - oauth: [pets.read]

Known false positives / limitations

OpenAPI 2.0 documents (securityDefinitions) are not checked. Scopes of non-OAuth2 schemes are not validated, since they are free form. Security schemes used in requirements but missing from the components are reported by other rules.

func SecurityScopesDefined

func SecurityScopesDefined() Rule

SecurityScopesDefined returns the extra-security-scopes-defined rule.

What it checks

Every security requirement, at the top level and on operations, must refer to a scheme defined in components.securitySchemes, and every scope that a requirement lists for an oauth2 scheme must be declared in at least one flow of that scheme. With reportUnused, scopes that an oauth2 scheme declares but no requirement uses are reported as well.

Why

A requirement that names an unknown scheme or scope can never be satisfied, and tooling either rejects the document or silently drops the protection. Unused scope declarations are dead documentation.

Where it comes from

The IBM API Handbook ruleset (security-scope consistency) and Redocly CLI (security-defined and its scope check). The two rows are merged.

Options

  • reportUnused (bool, default false): also report oauth2 scopes that are declared and never used by a requirement.

Bad

security:
  - oauth:
      - admin
components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://example.com/auth
          scopes:
            read: Read access

Good

security:
  - oauth:
      - read
components:
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://example.com/auth
          scopes:
            read: Read access

Known false positives / limitations

Scopes listed for schemes that are not oauth2 (apiKey, http, openIdConnect) are not checked, because the document cannot declare them. Only the components.securitySchemes of the document itself are consulted.

func ServerEnvironmentDescription

func ServerEnvironmentDescription() Rule

ServerEnvironmentDescription returns the extra-server-environment-description rule.

What it checks

The description of every entry of the root servers array must match the pattern, which by default looks for one of the names local, sandbox, alpha, beta, test, testing, stag, staging, prod, production, next, preprod or preproduction. The search is case-insensitive and not anchored to word boundaries, exactly as in the original, so a description such as "Contested device server" matches test. The rule only applies to OpenAPI 3 documents.

A server that has no description is not reported by default: the original rule applies its pattern to the description field only when it is present. Set requireDescription to also report a server without one.

When an API lists several servers, the description is the only thing that tells a reader which one is production and which is a sandbox. Naming the environment avoids calls against the wrong one.

Where it comes from

The Spectral OWASP ruleset, rule owasp:api9:2023-inventory-environment, which runs given $.servers.* with the pattern function on the description field and error severity.

Options

  • pattern (string, default (?i)(local|sandbox|alpha|beta|test|testing|stag| staging|prod|production|next|preprod|preproduction)): regular expression searched in the description. An empty string disables the rule, and a pattern that is not a valid regular expression disables it too.
  • requireDescription (bool, default false): also report servers without a description.

Bad

servers:
  - url: https://api.example.com
    description: The main server

Good

servers:
  - url: https://api.example.com
    description: Production server

Known false positives / limitations

Only the root servers array is inspected, not servers declared on a path item or an operation, as in the original. Descriptions in another language than English are reported unless the pattern is changed. The pattern uses the Go regexp syntax (RE2).

func ServerVariablesConsistent

func ServerVariablesConsistent() Rule

ServerVariablesConsistent returns the extra-server-variables-consistent rule.

What it checks

Every server object (root servers, path item servers, operation servers and the server of a link) is checked, and for each of its variables:

  • the variable must define a non-empty default;
  • when it defines an enum, the enum must not be empty and must contain the default;
  • when requireEnum is true, the variable must define an enum;
  • every {placeholder} in the server url must have a matching entry in variables.

Findings are reported on the variable, or on the server for a placeholder without a variable.

Why

Tools build the real URL by substituting each variable with its default. An absent or empty default, or a default outside the enum, yields an invalid URL and generators fail or silently choose a wrong value.

Where it comes from

Four rules of the source list are merged here: IBM (server variables have a non-empty default), Redocly (enum is not empty and contains the default), rate-my-openapi (each variable defines an enum, here the requireEnum option) and Spectral (server variables are consistent).

Options

  • requireEnum (boolean, default false): require every server variable to define an enum.

Bad

servers:
  - url: https://{region}.example.com
    variables:
      region:
        default: ""

Good

servers:
  - url: https://{region}.example.com
    variables:
      region:
        default: eu
        enum: [eu, us]

Known false positives

None known. Placeholders inside a url that is itself a $ref are not inspected.

func ServerVariablesDefined

func ServerVariablesDefined() Rule

ServerVariablesDefined returns the extra-server-variables-defined rule.

What it checks

Server URL templates and their variables must agree in both directions. Every {variable} in a server url must have a matching entry in the variables map of the same server, and every entry of that map must be used by the URL. Servers are checked at the document root, on path items and on operations. An undefined variable leaves the URL unresolvable; an unused one is dead configuration that readers will assume matters.

Where it comes from

Redocly CLI and rate-my-openapi, which both validate server variables against the URL template.

Options

None.

Bad

servers:
  - url: https://{region}.example.com
    variables:
      env:
        default: prod

Good

servers:
  - url: https://{region}.example.com
    variables:
      region:
        default: eu

Known false positives

None known. Server objects reached through $ref are skipped because the OpenAPI specification does not allow references there.

func ServerXInternal

func ServerXInternal() Rule

ServerXInternal returns the extra-server-x-internal rule.

What it checks

Every server object, in the root servers list, on path items and on operations, must define the x-internal extension with a boolean value (true or false). The name of the extension can be changed with an option.

Why

Documents that describe several environments often mix internal servers (staging, intranet gateways) with public ones. A mandatory marker makes the visibility an explicit decision for every server instead of an implicit default, so documentation tooling can reliably filter out internal servers before publishing.

Where it comes from

A Spectral ruleset convention (an x-internal property on every server).

Options

  • extension (string, default "x-internal"): the name of the extension that each server must define as a boolean.

Bad

servers:
  - url: https://api.example.com

Good

servers:
  - url: https://api.example.com
    x-internal: false
  - url: https://staging.example.com
    x-internal: true

Known false positives and limitations

The extension must be a literal YAML boolean; the string "true" is rejected. An empty extension option disables the rule. Servers declared only through $ref'd path items are checked where the path item is resolved.

func SingleTypePlusNull

func SingleTypePlusNull() Rule

SingleTypePlusNull returns the extra-single-type-plus-null rule.

What it checks

In OpenAPI 3.1 documents, the type list of a schema may hold at most one type besides "null". Once null is ignored, ["string"] and ["string", "null"] are fine, while ["string", "integer"] and ["string", "integer", "null"] are reported.

Why

A schema that accepts several unrelated types is hard to model in typed languages and in most code generators. A nullable value is the one union that maps cleanly everywhere, so IBM's guideline allows nullability and nothing else.

Where it comes from

IBM openapi-validator (ibm-avoid-multiple-types).

Options

None.

Bad

components:
  schemas:
    Id:
      type: [string, integer]

Good

components:
  schemas:
    Id:
      type: [string, "null"]

Known false positives / limitations

Only the type keyword of schemas is examined; unions modelled with oneOf are not. OpenAPI 3.0 documents are not checked since type is a single string there.

func SingleURIVersionSegment

func SingleURIVersionSegment() Rule

SingleURIVersionSegment returns the extra-single-uri-version-segment rule.

What it checks

A path key must not contain more than one version segment. A version segment is a whole path segment made of v (or V) and a number, optionally with minor parts, such as /v1, /v2 or /v1.2. A single version segment is allowed.

Why

The API version belongs to the URI once. Two version segments, as in /v1/orders/v2/items, mean that the version of the whole API and the version of a sub-resource are mixed, which makes clients hard to evolve and routing ambiguous.

Where it comes from

The Baloise Spectral ruleset (baloise-incubator/Spectral-ruleset, single-uri-version-segment).

Options

None.

Bad

paths:
  /v1/orders/v2/items:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /v1/orders/items:
    get:
      responses:
        "200":
          description: ok

Known false positives / limitations

A resource that is legitimately named like a version (for example a /v2 product code) is counted. Server URLs are not inspected, so a version in a server URL plus one in the path is not reported.

func StrictRefLocations

func StrictRefLocations() Rule

StrictRefLocations returns the extra-strict-ref-locations rule.

What it checks

A port of Redocly CLI's spec-strict-refs. The OpenAPI specification only makes some objects referenceable. The document is walked following the OpenAPI object model, and a $ref found in an object whose type is not in the list below is reported on the $ref keyword with the message "Field $ref is not expected here.".

Referenceable (a $ref is accepted): Schema, Response, Parameter, RequestBody, Example, Header, SecurityScheme, Link, Callback, PathItem, and MediaType in a content entry of OpenAPI 3.2.

Everything else rejects a $ref, for example: Info, Contact, License, Server, ServerVariable, Tag, ExternalDocs, Paths, Operation, Responses, Encoding, Discriminator, XML, OAuthFlows and OAuthFlow, security requirements, Components and each of its maps (components.schemas itself), and, before OpenAPI 3.2, MediaType.

Free-form regions are not examined: example, examples values, default, enum, const, and everything below x- extension keys.

Where it comes from

Redocly CLI, rule spec-strict-refs (packages/core/src/rules/common/spec-strict-refs.ts).

Options

None.

Bad

info:
  contact:
    $ref: "#/components/x-contact"
paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              $ref: "#/components/x-media"

Good

paths:
  /pets:
    $ref: "#/components/pathItems/Pets"

Known false positives and limitations

The document is classified by position in the standard object model, so an object in a position the model does not know (a misspelled keyword) is not examined. Only local structure is classified; the target of a $ref is checked where it is defined. Swagger 2.0 documents are not modelled.

func StringLengthAndPatternRequired

func StringLengthAndPatternRequired() Rule

StringLengthAndPatternRequired returns the extra-string-length-and-pattern-required rule.

What it checks

A faithful port of IBM's ibm-string-attributes. Every string schema must define pattern, minLength and maxLength so the set of valid values is clearly bounded; every non-string schema must not define them.

The schemas examined are the root schemas (components, parameters, request and response bodies, headers) and, below them, the properties, items, additionalProperties and patternProperties schemas plus the members of allOf, oneOf and anyOf (the nested schemas of those members are checked; the composed member itself is not, exactly as in IBM's validateNestedSchemas). Schemas below not, if, then and else are skipped.

Whether a schema is a string schema, and what its format, pattern, minLength, maxLength and enum are, is decided in a composition-aware way like IBM's schemaHasConstraint: a keyword counts when the schema declares it, when any allOf member does, or when every oneOf or anyOf member does ($refs to local components are followed).

For a string schema without an enum or const (either one anywhere in the composition bypasses every check, because the values are already bounded; the const keyword is an addition to IBM's rule, which predates OpenAPI 3.1):

  • pattern is required unless format is binary, byte, date, date-time or url, or one of the shapedFormats;
  • minLength is required unless format is date, identifier or url, or one of the shapedFormats;
  • maxLength is required unless format is date (the shapedFormats do not exempt it, since formats such as uri and email are unbounded);
  • minLength must not be greater than maxLength.

For a schema that declares a type other than string, a declared pattern, minLength or maxLength is reported at the keyword. A schema without any type (a mixin fragment meant for allOf) is not reported.

Where it comes from

IBM's openapi-validator (ibm-string-attributes, severity warn).

Options

  • requirePattern: require pattern. Default: true.

  • requireMinLength: require minLength. Default: true.

  • requireMaxLength: require maxLength. Default: true.

  • shapedFormats (list of strings): the formats whose values are never empty and already shaped, which satisfy the pattern and minLength demands. Default: date, date-time, time, duration, uuid, uri, uri-reference, iri, url, email, idn-email, hostname, idn-hostname, ipv4, ipv6, json-pointer, regex, byte. Set it to an empty list to require both on every string.

The requirePattern, requireMinLength and requireMaxLength options switch off the "missing" findings only; the not-a-string and minLength-greater-than-maxLength checks always run.

Bad

components:
  schemas:
    Thing:
      type: object
      properties:
        thing_id:
          type: string
        count:
          type: integer
          minLength: 1

Good

components:
  schemas:
    Thing:
      type: object
      properties:
        thing_id:
          type: string
          pattern: "^[a-z0-9]+$"
          minLength: 1
          maxLength: 64

Known false positives and limitations

IBM validates only schemas that are used by operations (after resolving $refs); this rule also validates every components.schemas entry, since usage cannot be traced without resolving the document, so an unused component is reported too. A $ref property is not followed into its target for the finding (the target is checked where it is defined). Free text such as descriptions legitimately has no pattern; set requirePattern to false.

func StringLengthLimits

func StringLengthLimits() Rule

StringLengthLimits returns the extra-string-length-limits rule.

What it checks

The minLength and maxLength keywords of every schema must be integers inside a sensible range:

  • minLength must be an integer of at least minLengthFloor (default 1, a positive number).
  • minLength and maxLength must not exceed lengthCeiling (default 4194304, 4 MiB).

Setting either option to zero or less switches that part of the check off.

Why

A minLength of zero (or a negative one) says nothing, since every string is at least that long, and usually comes from a generator that spells out defaults. Lengths beyond a few mebibytes are not meaningful for a string field that travels inside a JSON document, and tooling that allocates test data from the bound may run out of memory.

Where it comes from

specmatic, merging min-length-positive (minLength must be a positive integer) and string-max-length-ceiling (the 4 MB recommended maximum for string lengths).

Options

  • minLengthFloor (integer, default 1): the smallest allowed minLength. Set to 0 to accept minLength: 0 and only reject negative values and non-integers.
  • lengthCeiling (integer, default 4194304): the largest allowed minLength or maxLength.

Bad

components:
  schemas:
    Name:
      type: string
      minLength: 0
      maxLength: 1073741824

Good

components:
  schemas:
    Name:
      type: string
      minLength: 1
      maxLength: 255

Known false positives and limitations

With the default floor an explicit minLength: 0 is reported even though it is harmless; lower the floor to 0 for such documents. Lengths are only checked on schemas reachable from paths and components.

func SuccessResponseExample

func SuccessResponseExample() Rule

SuccessResponseExample returns the extra-success-response-example rule.

What it checks

Every media type of a success (2xx) response, in the list given by the mediaTypes option, must carry an example. An example is an example or examples keyword on the media type object, or an example or examples keyword on its schema ($ref schemas are followed).

Why

Examples are what readers copy from documentation and what mock servers and test tools replay. Success responses are the ones every consumer reads, so requiring examples there gives most of the benefit at a fraction of the effort of requiring them everywhere.

Where it comes from

IBM openapi-validator (ibm-success-response-example). vacuum's oas3-missing-example requires examples on every object instead.

Options

  • mediaTypes: the media types to check. Default: application/json.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
              example:
                name: Rex

Known false positives / limitations

Examples on individual properties of the schema do not count; the example must be on the media type or on the schema itself. Responses that are $ref objects are resolved and reported at their use.

func SuccessResponseHasSchema

func SuccessResponseHasSchema() Rule

SuccessResponseHasSchema returns the extra-success-response-has-schema rule.

What it checks

For every operation, the first 2xx response must declare a body schema: it must have content, and at least one of its media types must define a schema. Responses whose status code is listed in ignoredCodes (204 and 205 by default, which never carry a body) are skipped, as are HEAD operations.

Why

A success response without a schema leaves clients and test generators guessing at the shape of the data that comes back, and prevents response validation.

Where it comes from

ai-api-lint (success-response-has-schema).

Options

  • ignoredCodes (list of strings, default [204, 205]): success status codes that are allowed to have no schema.

Bad

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok

Good

paths:
  /pets:
    get:
      responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string

Known false positives / limitations

Only the first success response in document order is examined. Responses that redirect with a 3xx code or that stream binary data without a schema are reported only if they are 2xx and not ignored; add the code to ignoredCodes when it is intentionally schema-less.

func SummaryNoTrailingPeriod

func SummaryNoTrailingPeriod() Rule

SummaryNoTrailingPeriod returns the extra-summary-no-trailing-period rule.

What it checks

The summary of every operation must not end with a period. Summaries are short labels shown in navigation menus, tables of contents and generated client method documentation; a full stop makes them look like sentences and is inconsistent when the labels are listed.

Where it comes from

IBM's API Handbook ruleset (summary-no-trailing-period) and the Oxide OpenAPI lint (operation summaries must not end with a period). The two near-duplicate rows of the source list are merged into this one rule.

Options

None.

Bad

paths:
  /pets:
    get:
      summary: List all pets.

Good

paths:
  /pets:
    get:
      summary: List all pets

Known false positives

A summary that ends in an abbreviation such as "etc." is flagged even though the period belongs to the abbreviation. Reword the summary or suppress the rule for that operation. Ellipses ("...") are flagged too.

func TracingHeadersRequired

func TracingHeadersRequired() Rule

TracingHeadersRequired returns the extra-tracing-headers-required rule.

What it checks

Every path item must provide a distributed tracing context as header parameters. The check follows the original rule path item by path item:

  • If the parameters declared on the path item itself are valid, the path item passes, whatever its operations declare.
  • Otherwise each operation that declares parameters is examined on its own parameters (they are not merged with those of the path item), and the path item is reported, once, when any of them is not valid.

A list of parameters is valid when it either contains exactly the two B3 headers X-B3-TraceId and X-B3-SpanId (names compared case-insensitively), all with in: header, or contains exactly one traceparent header (W3C Trace Context) with in: header. Parameters given as a $ref are resolved first.

As in the original, an operation that declares no parameters at all is not examined, so a path item whose operations have no parameters passes. Set requireOnAllOperations to treat such an operation as invalid too.

Requests that carry a trace context can be followed across services, which is what makes incidents debuggable in a system with many hops.

Where it comes from

The baloise-incubator Spectral ruleset, rule must-use-tracing (MUST request must provide tracing, Zalando guideline 233 adapted), implemented by the validate-tracing function with given $.paths.* and error severity.

Options

  • requireOnAllOperations (bool, default false): also report a path item when one of its operations declares no parameters and the path item has no valid tracing parameters of its own.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
      responses: {}

Good

paths:
  /pets:
    parameters:
      - name: traceparent
        in: header
        schema:
          type: string
    get:
      responses: {}

Known false positives / limitations

Parameters inherited from the path item are not combined with those of an operation, so B3 headers split over both levels are reported, exactly as in the original. APIs whose gateway adds the tracing headers and which therefore do not list them in the contract are reported; disable the rule there.

func URLFieldFormat

func URLFieldFormat() Rule

URLFieldFormat returns the extra-url-field-format rule.

What it checks

Every field of the document that holds a URL must contain a well formed one. The fields that are inspected are:

  • info.termsOfService, info.contact.url and info.license.url;
  • the url of externalDocs on the document, on tags and on operations;
  • the url of every server (variables in braces are replaced by a placeholder before parsing, and a relative URL is accepted because the specification allows it);
  • authorizationUrl, tokenUrl and refreshUrl of OAuth flows, and openIdConnectUrl of security schemes;
  • xml.namespace of schemas.

A value is reported when it cannot be parsed as a URL, contains whitespace, or (for every field except server urls and OAuth urls, which may be relative) is not absolute, meaning it has no scheme.

Tools follow these links, render them as hyperlinks or hand them to HTTP clients, so a typo or a relative link in a place that needs an absolute one breaks them.

Where it comes from

KaiZen OpenAPI Parser, which validates URL typed fields.

Options

None.

Bad

info:
  contact:
    url: example.com/support

Good

info:
  contact:
    url: https://example.com/support

Known false positives

A server URL with a template that stands for more than a host part, for example a whole URL held in a variable, is accepted without being checked further. Only the first url of a field is checked; no network access is made to see whether the address exists.

func UnevaluatedPropertiesMustBeFalse

func UnevaluatedPropertiesMustBeFalse() Rule

UnevaluatedPropertiesMustBeFalse returns the extra-unevaluated-properties-must-be-false rule.

What it checks

In OpenAPI 3.1 documents, a schema that sets unevaluatedProperties must set it to the boolean false. Schemas without the keyword are not affected, and the rule does not run on OpenAPI 3.0 documents. A true value or a schema value is reported on the keyword.

Why

unevaluatedProperties: false closes an object after composition (allOf, oneOf, if/then). Any other value either reopens the object to arbitrary extra properties or hides a second set of rules that clients cannot reliably follow; policy-wise the choice is between closed and silent.

Where it comes from

IBM's API Handbook ruleset (ibm-unevaluated-properties).

Options

None.

Bad

components:
  schemas:
    Pet:
      type: object
      unevaluatedProperties: true

Good

components:
  schemas:
    Pet:
      type: object
      unevaluatedProperties: false

Known false positives

Schemas that deliberately accept typed extras with a schema value, such as unevaluatedProperties: {type: string}, are flagged and need a suppression.

func UniqueTagNames

func UniqueTagNames() Rule

UniqueTagNames returns the extra-unique-tag-names rule.

What it checks

The names in the top-level tags list must be unique. A tag name is the key that operations use to group themselves, so two tag objects with one name make the grouping ambiguous and documentation tools show one of them at random. Every repeated entry after the first is reported at its name; unlike some linters that stop at the first duplicate, all duplicates are listed.

Where it comes from

Three near-identical rules merged into one: duplicate-tag-name from the spec-validator, tags-unique-names from Spectral and unique-tag-names from rate-my-openapi.

Options

  • caseInsensitive: compare names ignoring case and surrounding white space, so "Pets" and "pets" count as duplicates. Default: false.

Bad

tags:
  - name: pets
  - name: pets

Good

tags:
  - name: pets
  - name: owners

Known false positives

None known. Tags without a name are ignored here; other rules require the name.

func Unreachable405

func Unreachable405() Rule

Unreachable405 returns the extra-unreachable-405 rule.

What it checks

An operation must not declare a 405 (Method Not Allowed) response when every HTTP method is already declared for its path. The set of methods is configurable and by default is get, put, post, delete, options, head, patch and trace, the methods OpenAPI knows. Every 405 response of such a path is reported.

Why

A server answers 405 when a request uses a method the resource does not implement. If the path declares every method, there is no method left to be rejected, so the 405 can never occur and the documented response is misleading noise in generated clients and tests.

Where it comes from

specmatic (unreachable 405 response).

Options

  • methods (list of strings, default get, put, post, delete, options, head, patch, trace): the methods that must all be declared for the 405 to count as unreachable. Narrow the list to the methods your server really dispatches on.

Bad

paths:
  /pets:
    get:
      responses:
        "405":
          description: not allowed
    put: {responses: {"200": {description: ok}}}
    post: {responses: {"200": {description: ok}}}
    delete: {responses: {"200": {description: ok}}}
    options: {responses: {"200": {description: ok}}}
    head: {responses: {"200": {description: ok}}}
    patch: {responses: {"200": {description: ok}}}
    trace: {responses: {"200": {description: ok}}}

Good

paths:
  /pets:
    get:
      responses:
        "405":
          description: not allowed

Known false positives and limitations

Only the methods declared in the document are known; a server may still answer 405 for a method the document declares but a gateway blocks. Path items given by $ref are judged by the item they point at. An empty methods list disables the rule.

func Unsupported31Keywords

func Unsupported31Keywords() Rule

Unsupported31Keywords returns the extra-unsupported-3-1-keywords rule.

What it checks

An OpenAPI 3.1 document must not use top-level keywords that tooling around the document does not support. By default these are jsonSchemaDialect and webhooks.

Why

Several widely used SDK generators and gateways accept 3.1 documents but ignore these parts, so the information silently disappears from generated clients and documentation. Flagging the keywords tells authors that they will not take effect.

Where it comes from

IBM openapi-validator (ibm-no-unsupported-keywords).

Options

  • keywords: the top-level keywords that are reported. Default: jsonSchemaDialect, webhooks.

Bad

openapi: 3.1.0
info: {title: Test, version: "1.0"}
webhooks:
  newPet:
    post: {}

Good

openapi: 3.1.0
info: {title: Test, version: "1.0"}
paths: {}

Known false positives / limitations

The keywords are valid OpenAPI 3.1; the rule is only useful when the toolchain is known not to support them. Nested use of the names (for example a schema property called webhooks) is not reported.

func UnusedGlobalTags

func UnusedGlobalTags() Rule

UnusedGlobalTags returns the extra-unused-global-tags rule.

What it checks

Every tag declared in the top-level tags list must be referenced by the tags of at least one operation. Tags are matched by name. A document without a top-level tags list is not checked.

Why

Declared but unused tags show up as empty groups in documentation, add noise to the navigation and usually mean that an operation was re-tagged or removed without tidying the tag list.

Where it comes from

The IBM API Handbook ruleset (ibm-unused-tags).

Options

None.

Bad

tags:
  - name: pets
  - name: orders
paths:
  /pets:
    get:
      tags: [pets]

Good

tags:
  - name: pets
paths:
  /pets:
    get:
      tags: [pets]

Known false positives / limitations

A tag that is used only by operations reached through an external $ref path item, or only by webhooks and callbacks, is reported as unused.

func ValidMediaTypeSyntax

func ValidMediaTypeSyntax() Rule

ValidMediaTypeSyntax returns the extra-valid-media-type-syntax rule.

What it checks

Every key of the content map of a request body (inline or under components.requestBodies) must be a well formed media type: a top-level type from the configured list, a slash, and a subtype made of the characters RFC 6838 allows. Parameters after a semicolon, such as charset=utf-8, are ignored, and the wildcards */* and type/* are accepted. The finding is placed on the media type entry.

Why

A misspelt media type such as appliation/json, json or application\json is not recognised by servers or client generators, so the body is silently treated as unsupported.

Where it comes from

rate-my-openapi (request body content keys must have a valid mime prefix).

Options

  • types (list of strings, default application, audio, font, image, message, model, multipart, text, video): the accepted top-level types.

Bad

requestBody:
  content:
    json:
      schema: {type: object}

Good

requestBody:
  content:
    application/json:
      schema: {type: object}

Known false positives

Vendor trees that use a non-standard top-level type, such as x-world/x-vrml, are flagged until the type is added to the types option. Only request bodies are checked; response content is not.

func WebhookRestrictions

func WebhookRestrictions() Rule

WebhookRestrictions returns the extra-webhook-restrictions rule.

What it checks

Webhooks, the OpenAPI 3.1 top-level webhooks map, describe requests that the API provider sends to the consumer, so two features of the specification make no sense there. With noCallbacks, an operation of a webhook must not define callbacks (a webhook is already a callback). With noServers, neither a webhook path item nor any of its operations may define servers, because the receiving URL is chosen by the consumer and not by the provider. Every violation is reported at the offending callbacks or servers keyword.

Where it comes from

Spectral's OpenAPI ruleset, which has webhook-no-callbacks and webhook-no-servers, merged into this rule; each half is switched by an option.

Options

  • noCallbacks: forbid callbacks in webhook operations. Default: true.
  • noServers: forbid servers in webhook path items and operations. Default: true.

Bad

webhooks:
  newPet:
    servers:
      - url: https://consumer.example.com
    post:
      callbacks: {}
      responses: {}

Good

webhooks:
  newPet:
    post:
      responses: {}

Known false positives

None known. The rule only applies to OpenAPI 3.1 documents, where webhooks exist; callbacks under ordinary paths are unaffected.

func WellDefinedDictionaries

func WellDefinedDictionaries() Rule

WellDefinedDictionaries returns the extra-well-defined-dictionaries rule.

What it checks

A faithful port of the IBM function wellDefinedDictionaries. For every object schema (one with type object, or without a type but with properties, additionalProperties or patternProperties; composition is followed as in IBM schemaHasConstraint: an allOf member suffices, oneOf and anyOf need every member) that is not itself the value schema of a dictionary:

  • a schema that is not a dictionary and defines no properties is reported ("Object schemas must define either properties, or (additional/pattern)Properties with a concrete type"), controlled by requireObjectDefinition;
  • a dictionary (additionalProperties other than false, or patternProperties) that also defines properties is reported ("they cannot be both");
  • with requireValueType, a dictionary whose value schema (every patternProperties value is checked) is not an object or does not define a type, directly or through composition, is reported, so additionalProperties: true and {} are reported;
  • with forbidNestedDictionaries, a dictionary whose value schema is itself a dictionary is reported.

Findings are reported at the object schema, as IBM does. $ref values are resolved. Members of allOf, oneOf, anyOf and not are not evaluated on their own; only the schema that composes them is.

Why

A schema that mixes fixed properties with free-form additional properties is ambiguous: generators cannot decide between a class and a map, and clients lose the type of the extra values. Untyped values and dictionaries of dictionaries are hard to model in strongly typed languages and to evolve compatibly.

Where it comes from

IBM openapi-validator (ibm-well-defined-dictionaries).

Options

  • requireValueType (bool, default true): require a typed value schema.
  • forbidNestedDictionaries (bool, default true): reject dictionaries whose values are dictionaries.
  • requireObjectDefinition (bool, default true): report object schemas that define neither properties nor a dictionary.

Bad

components:
  schemas:
    Labels:
      type: object
      properties:
        name: {type: string}
      additionalProperties:
        type: string
    Free:
      type: object

Good

components:
  schemas:
    Labels:
      type: object
      additionalProperties:
        type: string

Known false positives and limitations

IBM only evaluates schemas reachable from operations and parameters, while this rule also evaluates every schema under components.schemas, so an unused component can be reported. Only local $ref values are followed.

func WellKnownPropertyTypes

func WellKnownPropertyTypes() Rule

WellKnownPropertyTypes returns the extra-well-known-property-types rule.

What it checks

Properties that carry the same meaning everywhere must have the same type. Properties named id must be strings. Properties named created or modified must be strings with the format date-time. Which names are checked and which types they get can be set with options. A property whose type is missing, or whose type or format differs, is reported. Type lists of OpenAPI 3.1 are accepted when, ignoring null, they contain only the expected type.

Why

Consumers write generic code for identifiers and timestamps. When one resource uses an integer id and another a string, or timestamps as numbers in some places and date-time strings in others, that code needs special cases and generated clients differ between resources.

Where it comes from

Zally (CommonFieldTypesRule, Zalando guideline on common field names).

Options

  • idProperties: property names that must be of idType. Default: id.
  • idType: the type of the identifier properties. Default: string.
  • timestampProperties: property names that must be timestamps. Default: created, modified.
  • timestampType: the type of the timestamp properties. Default: string.
  • timestampFormat: the format of the timestamp properties. Default: date-time.

Bad

components:
  schemas:
    Pet:
      type: object
      properties:
        id: {type: integer}
        created: {type: string}

Good

components:
  schemas:
    Pet:
      type: object
      properties:
        id: {type: string}
        created: {type: string, format: date-time}

Known false positives / limitations

A property called id in a schema where an integer key is intended is reported even when that is deliberate. Names are matched exactly and case-sensitively. A property that is only a $ref is judged by the type of its target.

func WireEnumNoCamelCase

func WireEnumNoCamelCase() Rule

WireEnumNoCamelCase returns the extra-wire-enum-no-camel-case rule.

What it checks

String values of a schema's enum must not contain a lower-case letter that is immediately followed by an upper-case letter, which is the signature of camelCase and PascalCase spellings (for example inProgress or created_atUTC). SCREAMING_SNAKE_CASE, snake_case and kebab-case values are accepted.

Why

Enum values are part of the wire format and are fixed forever once clients depend on them. Code generators derive constant names from them, and camelCase values convert badly to the idiomatic constant style of other languages, so a separator-based spelling is the safer choice.

Where it comes from

Redocly CLI (wire-enum-no-camel-case, which tests enum values against the expression [a-z][A-Z]).

Options

None.

Bad

components:
  schemas:
    Status:
      type: string
      enum: [inProgress, done]

Good

components:
  schemas:
    Status:
      type: string
      enum: [in_progress, done]

Known false positives / limitations

Values that are not camelCase but contain a lower-to-upper transition, such as product names (iPhone), are reported. Non-string enum values are ignored.

func WireParameterNoCamelCase

func WireParameterNoCamelCase() Rule

WireParameterNoCamelCase returns the extra-wire-parameter-no-camel-case rule.

What it checks

The name of a parameter must not contain a lower case letter directly followed by an upper case letter, which is what makes a name camelCase. Every parameter of a path item, of an operation and of components/parameters is checked. Names such as Idempotency-Key, Origin, page_size and _zflow_request are accepted because they have no such pair.

Query strings, paths and header names are case-insensitive or conventionally lower case on the wire, so camelCase names are an easy source of bugs in proxies and clients. Kebab or snake case names do not have that problem.

Where it comes from

Redocly CLI, the community rule that rejects camelCase parameter names (the pattern [a-z][A-Z]).

Options

  • pattern (string, default [a-z][A-Z]): regular expression a parameter name must not match. An empty string disables the rule, and a pattern that is not a valid regular expression disables it too.

Bad

paths:
  /pets:
    get:
      parameters:
        - name: pageSize
          in: query
          schema:
            type: integer

Good

paths:
  /pets:
    get:
      parameters:
        - name: page_size
          in: query
          schema:
            type: integer

Known false positives

Established headers written in camel case by a third party (for example X-Amz-Meta headers sent as xAmzMeta) are reported. Parameters that are $ref entries are checked where they are defined, in components/parameters.

func WriteOperationRequiresRequestBody

func WriteOperationRequiresRequestBody() Rule

WriteOperationRequiresRequestBody returns the extra-write-operation-requires-request-body rule.

What it checks

Operations with a write method must declare a requestBody. Only the absence of the requestBody key is reported; an empty requestBody object is accepted, as it is present. The finding is reported on the operation.

Why

A POST, PUT or PATCH without a request body describes a write that carries no data, which is almost always an omission. Clients and generated SDKs cannot tell what to send.

Where it comes from

ai-api-lint (operations with post, put or patch must declare a request body).

Options

  • methods (list of strings, default post, put, patch): the HTTP methods that need a request body.

Bad

paths:
  /pets:
    post:
      responses:
        "201":
          description: created

Good

paths:
  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema: {type: object}
      responses:
        "201":
          description: created

Known false positives

Action endpoints that trigger work without input, such as POST /orders/{id}/cancel, are flagged. Remove post from the methods option, or suppress the rule for such operations.

func WriteResponseReturnsResourceOrLocation

func WriteResponseReturnsResourceOrLocation() Rule

WriteResponseReturnsResourceOrLocation returns the extra-write-response-returns-resource-or-location rule.

What it checks

Every 2xx response of a POST, PUT or PATCH operation must tell the caller what happened to the resource. It passes when it has a content map (the resource, or a description of the result is returned) or, for the codes 201 and 204, when it declares a Location response header (matched case-insensitively) that points at the resource. Any other 2xx response without content is reported, as is a 201 or 204 that has neither content nor Location. Response objects reached through $ref are resolved.

Where it comes from

apilint, which asks that writes return the resource or a Location header.

Options

  • ignoreCodes: status codes that may be empty without a Location header. Default: 202, because an accepted asynchronous request has no resource yet.

Bad

paths:
  /pets:
    post:
      responses:
        "201":
          description: created

Good

paths:
  /pets:
    post:
      responses:
        "201":
          description: created
          headers:
            Location:
              schema:
                type: string

Known false positives

Command style endpoints (POST /pets/{id}/archive) that legitimately return 200 or 204 without a body are flagged; list their codes in ignoreCodes or return a small result object.

func (Rule) GetCategory

func (r Rule) GetCategory() string

GetCategory implements model.RuleFunction.

func (Rule) GetSchema

func (r Rule) GetSchema() model.RuleFunctionSchema

GetSchema implements model.RuleFunction.

func (Rule) ID

func (r Rule) ID() string

ID returns the rule identifier, which is also the custom function name.

func (Rule) RuleEntry

func (r Rule) RuleEntry() *model.Rule

RuleEntry returns the model.Rule that wires the function into a ruleset, carrying the given JSONPath, the severity and the default options.

func (Rule) RuleEntryWith

func (r Rule) RuleEntryWith(overrides map[string]any) *model.Rule

RuleEntryWith is RuleEntry with the given functionOptions layered over the defaults of the rule.

func (Rule) RunRule

func (r Rule) RunRule(nodes []*yaml.Node, ctx model.RuleFunctionContext) []model.RuleFunctionResult

RunRule implements model.RuleFunction. It hands every node matched by the given JSONPath to the check and converts the findings into vacuum results.

func (Rule) Spec

func (r Rule) Spec() Spec

Spec returns the declarative description of the rule.

type Spec

type Spec struct {
	// Name is the kebab-case rule name without the IDPrefix.
	Name string
	// Description is the one-line statement of what the rule checks.
	Description string
	// HowToFix tells the user how to resolve a violation.
	HowToFix string
	// Severity is one of the model.Severity constants.
	Severity string
	// Given is the JSONPath whose matches are handed to Check.
	Given string
	// Type is the vacuum rule type, "style" or "validation".
	Type string
	// Formats restricts the rule to the listed document formats. It is empty
	// for rules that apply to every OpenAPI version.
	Formats []string
	// Options lists the functionOptions the rule understands.
	Options []Option
	// Check is the implementation of the rule.
	Check Check
}

Spec is the declarative description of a rule.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL