Skip to content

04Reference

Diagnostics

Every diagnostic code, what it means and, for many, an example the compiler ran with the fix.

Every problem is reported as a diagnostic with a stable code, a severity, a message, and when available a location (file, JSON pointer, line and column), the operation it relates to and a hint. Codes are stable across patch releases; --json output includes them for tooling.

  • error — generation stops and nothing is written.
  • warning — output is generated; something was ignored, interpreted or may not match the specification exactly.
  • info (notes) — shown with --verbose.

The CLI exits with 2 when an error is a configuration problem (config/*) and with 1 for other errors. Terminal output shows control characters from the specification or plugins as \xNN escapes; --json output contains the text unchanged (JSON-escaped).

Configuration

config/not-founderror

No config file in the working directory

config/load-failederror

The config file threw or could not be imported

config/plugin-load-failederror

A plugin reference ('./plugin.mjs', 'package' or ['package', options]) could not be resolved or imported, or did not produce a valid plugin

config/invaliderror

Unknown option or wrong value (with a suggestion); in JSON and YAML configs with the line and column

Example: A misspelled option

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
swaggerz generate
error config/invalid ouput: Unknown option.
hint Did you mean "output"?

Fix. Correct the option name; the hint suggests the closest valid one.

config/unsafe-outputerror

The output directory contains the project, the config or the spec (symbolic links and letter case are resolved first); exit code 2

Specification

spec/load-failederror

The document could not be read or parsed (with line and column)

spec/parse-errorerror

The document could not be read or parsed (with line and column)

Example: Broken YAML

openapi.yaml
openapi: 3.1.0
info:
title: [Example
swaggerz generate
error spec/parse-error Invalid YAML: Flow sequence in block collection must be sufficiently indented and end with a ] at line 4, column 1:
at openapi.yaml:4:1

Fix. Fix the syntax at the reported line and column.

spec/not-an-objecterror

Not a Swagger/OpenAPI document

spec/unknown-formaterror

Not a Swagger/OpenAPI document

spec/unsupported-versionerror

Unsupported or malformed swagger/openapi field

spec/invalid-versionerror

Unsupported or malformed swagger/openapi field

spec/version-mismatcherror

The document's version differs from spec.version

Example: The config expects 3.1, the document is 3.0

openapi.yaml
openapi: 3.0.3
info:
title: Example
version: '1.0'
paths: {}
swaggerz generate
error spec/version-mismatch The config expects OpenAPI 3.1 (spec.version: '3.1'), but the document declares OpenAPI 3.0 (3.0.3).
at openapi.yaml:1:1 (#/openapi)
hint Set spec.version to '3.0' if the document is correct, or use 'auto' to accept any supported version.

Fix. Set spec.version to the version the document declares, or to 'auto'.

spec/unquoted-versionwarning

openapi, swagger or info.version given as a YAML number (quote it)

Example: A version written as a YAML number

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: 1.0
paths: {}
swaggerz generate
warning spec/unquoted-version `info.version` is the number 1; quote it to keep its exact text (for example '1').
at openapi.yaml:4:3 (#/info/version)

Fix. Quote the version (version: '1.0'), otherwise YAML reads it as the number 1.

spec/missing-fielderrorwarning

Required document fields are missing

spec/non-standard-refinfo

A $ref where the specification allows none (an Operation Object in a description split into files); it is followed

spec/invalid-patherrorwarning

Malformed document parts

spec/invalid-operationerrorwarning

Malformed document parts

spec/invalid-parametererrorwarning

Malformed document parts

spec/invalid-parameterserrorwarning

Malformed document parts

spec/invalid-responseerrorwarning

Malformed document parts

spec/invalid-securityerrorwarning

Malformed document parts

spec/unsupported-dialectwarning

Unknown jsonSchemaDialect

spec/invalid-tag-parentwarning

OpenAPI 3.2: a tag's parent is not declared or makes a cycle; the tag is treated as top-level

Overlays

overlay/load-failederror

An overlay in spec.overlays could not be read or parsed

overlay/unsupported-versionerrorwarning

The overlay version is not 1.x (error) or newer than 1.2 (warning: applied with the 1.2 rules)

overlay/invaliderrorwarning

The overlay or an action is malformed (no actions, no target, removing $), or an action does nothing

overlay/invalid-targeterror

An action target is not RFC 9535 JSONPath

Example: A target that is not RFC 9535 JSONPath

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
fixes.overlay.yaml
overlay: 1.1.0
info: { title: Fixes, version: 1.0.0 }
actions:
- target: $.paths[?@.summary =~ 'internal']
remove: true
swaggerz generate
error overlay/invalid-target Invalid JSONPath $.paths[?@.summary =~ 'internal']: Expected "]" (at character 20)
at fixes.overlay.yaml:4:5 (#/actions/0/target)
hint Overlays use RFC 9535 JSONPath: member names with special characters need brackets, e.g. $.paths['/pets'].

Fix. Use RFC 9535's own functions instead of other dialects' operators: $.paths[?search(@.summary, 'internal')].

overlay/no-matchwarning

An action target selects nothing; the action changes nothing

Example: An overlay action whose target matches nothing

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
responses: { '204': { description: Empty } }
fixes.overlay.yaml
overlay: 1.1.0
info: { title: Fixes, version: 1.0.0 }
actions:
- target: $.paths['/pet'].get
update: { operationId: listAllPets }
swaggerz generate
warning overlay/no-match Overlay target $.paths['/pet'].get matches nothing; the action changes nothing.
at fixes.overlay.yaml:4:5 (#/actions/0/target)
hint The specification may have changed since the overlay was written.

Fix. Update the target: the specification has probably changed since the overlay was written.

overlay/incompatible-updateerror

An update or copy value cannot be merged into the target (e.g. an object into a string)

overlay/invalid-copyerror

A copy source does not select exactly one node

overlay/invalid-referenceerror

An Overlay 1.2 action $ref does not point to components.actions

overlay/appliedinfo

How many actions of an overlay were applied

References

ref/invaliderror

A $ref is malformed or points nowhere

ref/unresolvederror

A $ref is malformed or points nowhere

ref/missing-targeterror

A $ref is malformed or points nowhere

Example: A reference to a schema that does not exist

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Pet:
type: object
properties:
category:
$ref: '#/components/schemas/Categry'
Category:
type: object
swaggerz generate
error ref/missing-target $ref "#/components/schemas/Categry" points to "/components/schemas/Categry", which does not exist in openapi.yaml.
at openapi.yaml:11:9 (#/components/schemas/Pet/properties/category)

Fix. Point the $ref at an existing component (here, Category).

ref/circularerror

A chain of references never reaches a schema

Example: Two components that only refer to each other

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
A:
$ref: '#/components/schemas/B'
B:
$ref: '#/components/schemas/A'
swaggerz generate
error ref/circular Circular $ref chain: these schemas only refer to each other.
at openapi.yaml:8:5 (#/components/schemas/A)

Fix. Give one of the schemas a definition of its own; recursion through properties is fine.

ref/too-deeperror

A chain of references never reaches a schema

ref/external-blockederror

Blocked by the reference policy (hint explains how to allow it)

Example: A remote reference with the default policy

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Pet:
$ref: 'https://schemas.example.com/pet.yaml'
swaggerz generate
error ref/external-blocked External reference to https://schemas.example.com/pet.yaml was blocked: remote references are disabled (spec.refs.external = "local").
at openapi.yaml:8:5 (#/components/schemas/Pet)
hint Set spec.refs.external to "remote" and add "schemas.example.com" to spec.refs.allowedHosts.

Fix. Set spec.refs.external: 'remote' and add the host to spec.refs.allowedHosts, or download the file next to the specification.

ref/external-load-failederror

External document problems; the document limit is reported once and can be raised with spec.refs.maxDocuments

ref/too-many-documentserror

External document problems; the document limit is reported once and can be raised with spec.refs.maxDocuments

Schemas

schema/invaliderror

Malformed schemas

schema/invalid-typeerror

Malformed schemas

schema/invalid-discriminatorerror

Malformed schemas

schema/too-deeperror

Inline nesting beyond 512 levels

schema/foreign-keywordwarning

Keyword from another version, honored

schema/unsupported-keywordwarning

$dynamicRef, $recursiveRef, or a 3.1-only keyword (if, dependentSchemas, …) in a 3.0 document, ignored

Example: A 3.1 keyword in a 3.0 document

openapi.yaml
openapi: 3.0.3
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Shipping:
type: object
properties:
country: { type: string }
if:
properties:
country: { const: US }
then:
required: [zip]
swaggerz generate
warning schema/unsupported-keyword `if` is not supported and is ignored; the generated type may be wider than the schema.
at openapi.yaml:8:5 (#/components/schemas/Shipping)
warning schema/unsupported-keyword `then` is not supported and is ignored; the generated type may be wider than the schema.
at openapi.yaml:8:5 (#/components/schemas/Shipping)

Fix. Move the document to OpenAPI 3.1, or express the rule in the description.

schema/assertion-keywordinfo

not, if/then/else, dependentSchemas, dependentRequired: not expressible in TypeScript types, enforced by generated Zod schemas

Example: A rule TypeScript cannot express

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
NotEmpty:
type: string
not:
const: ''
swaggerz generate
info schema/assertion-keyword `not` cannot be expressed in TypeScript types (they may be wider than the schema); generated Zod schemas enforce it.
at openapi.yaml:8:5 (#/components/schemas/NotEmpty)

Fix. Nothing to fix: enable features.validation to enforce it at runtime.

schema/validation-only-keywordinfo

Keyword that only affects validation

schema/ref-siblings-ignoredwarning

Version-specific semantics applied

schema/nullable-31warning

Version-specific semantics applied

Example: nullable in an OpenAPI 3.1 document

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Name:
type: string
nullable: true
swaggerz generate
warning schema/nullable-31 `nullable` is not part of OpenAPI 3.1 and is ignored.
at openapi.yaml:8:5 (#/components/schemas/Name)
hint Use `type: [<type>, "null"]` or `oneOf` with `{ type: "null" }`.

Fix. Use type: [string, 'null'], the JSON Schema 2020-12 spelling of a nullable type.

schema/null-typewarning

Version-specific semantics applied

schema/type-arraywarning

Version-specific semantics applied

schema/tuple-itemswarning

Version-specific semantics applied

schema/exclusive-booleanwarning

Version-specific semantics applied

schema/empty-enumwarning

Questionable schemas

schema/enum-type-mismatchwarning

Questionable schemas

Example: Enum values of the wrong type

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Status:
type: string
enum: [active, 2]
swaggerz generate
warning schema/enum-type-mismatch Enum values 2 do not match type "string".
at openapi.yaml:10:7 (#/components/schemas/Status/enum)

Fix. Make every value match the declared type.

schema/empty-compositionwarning

Questionable schemas

schema/discriminator-ignoredwarning

Questionable schemas

schema/array-without-itemsinfo

Array elements typed as unknown

Example: An array without items in OpenAPI 3.0

openapi.yaml
openapi: 3.0.3
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Tags:
type: array
swaggerz generate
info schema/array-without-items Array schema without `items`; elements are typed as unknown.
at openapi.yaml:8:5 (#/components/schemas/Tags)

Fix. Declare items so the elements get a type instead of unknown.

Operations

operation/duplicate-idwarning

Duplicate operationId; names are disambiguated

Example: Two operations with the same operationId

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
responses: { '204': { description: Empty } }
/cats:
get:
operationId: listPets
responses: { '204': { description: Empty } }
swaggerz generate
warning operation/duplicate-id operationId "listPets" is used by GET /pets, GET /cats; generated names are disambiguated.
at openapi.yaml:11:5 (#/paths/~1cats/get)

Fix. Give every operation its own operationId; an overlay can do it for specifications you do not own.

operation/missing-path-parameterwarning

Path template and parameters disagree

Example: A path template without its parameter

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets/{petId}:
get:
operationId: getPet
responses: { '204': { description: Empty } }
swaggerz generate
warning operation/missing-path-parameter Path parameter "petId" is used in the path but not declared; it is typed as string.
at openapi.yaml:7:5 (#/paths/~1pets~1{petId}/get)
in GET /pets/{petId} (getPet)

Fix. Declare petId as an in: path parameter of the path or the operation.

operation/unused-path-parameterwarning

Path template and parameters disagree

operation/optional-path-parameterwarning

Path template and parameters disagree

operation/duplicate-parametererror

Invalid parameter combinations

operation/multiple-bodieserror

Invalid parameter combinations

operation/body-and-formerror

Invalid parameter combinations

operation/invalid-statuswarning

Ignored or adjusted operation parts

operation/invalid-stylewarning

Ignored or adjusted operation parts

operation/invalid-collection-formatwarning

Ignored or adjusted operation parts

operation/empty-request-bodywarning

Ignored or adjusted operation parts

operation/file-without-multipartwarning

Ignored or adjusted operation parts

operation/body-on-getwarning

Ignored or adjusted operation parts

operation/ignored-headerinfo

Accept, Content-Type or Authorization header parameter ignored, as OpenAPI 3 requires

Example: An Accept header parameter

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
parameters:
- name: Accept
in: header
schema: { type: string }
responses: { '204': { description: Empty } }
swaggerz generate
info operation/ignored-header Header parameter "Accept" is ignored; it is controlled by the request content or authentication.
at openapi.yaml:10:11 (#/paths/~1pets/get/parameters/0)
in GET /pets (listPets)

Fix. Remove the parameter: OpenAPI 3 describes Accept through the response content types.

operation/invalid-querystringerror

OpenAPI 3.2: more than one in: querystring parameter, or one combined with in: query parameters

operation/reserved-methoderror

OpenAPI 3.2: an additionalOperations key is a method with its own Path Item field (GET, QUERY, …) or not a valid HTTP method

operation/invalid-methoderror

OpenAPI 3.2: an additionalOperations key is a method with its own Path Item field (GET, QUERY, …) or not a valid HTTP method

operation/querystring-credentialswarning

OpenAPI 3.2: an API key sent in: query cannot be added to a JSON or text querystring; requirements that need it are skipped

operation/item-schemainfo

OpenAPI 3.2: content described only by itemSchema (JSON Lines, server-sent events) is typed and read as text

Security

security/invalid-schemeerrorwarning

Security problems

security/unknown-schemeerrorwarning

Security problems

Example: A security requirement naming no scheme

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
security:
- apiKey: []
responses: { '204': { description: Empty } }
swaggerz generate
warning security/unknown-scheme Security requirement references unknown scheme "apiKey"; it is ignored.
at openapi.yaml:10:11 (#/paths/~1pets/get/security/0/apiKey)

Fix. Declare the scheme under components.securitySchemes, or correct its name.

Naming

naming/collisionwarning

A name was taken; a suffix was added

Example: Two operationIds that become the same function name

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: list-pets
responses: { '204': { description: Empty } }
/pets/all:
get:
operationId: listPets
responses: { '204': { description: Empty } }
swaggerz generate
warning naming/collision Operation name "listPets" (GET /pets/all) is already taken; it is exported as "listPets2".

Fix. Rename one of the operations, or choose names with the operationName plugin hook.

Data fetching

query/invalid-page-paramerror

The configured infinite query parameter does not exist

Example: An infinite query on a parameter that does not exist

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
parameters:
- name: page
in: query
schema: { type: integer }
responses: { '204': { description: Empty } }
swaggerz generate
error query/invalid-page-param Infinite query for GET /pets: "cursor" is not a query parameter of the operation.
hint Use one of: page.

Fix. Name the query parameter that carries the page (here page).

query/unknown-operationwarning

A key of infinite or invalidates names no operation, or one of the wrong kind (a mutation in infinite, a query in invalidates)

query/unknown-targetwarning

An invalidates target is neither a query (name or operationId) nor a tag, or names a tag without queries

Example: Invalidating a query that does not exist

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths:
/pets:
get:
operationId: listPets
responses: { '204': { description: Empty } }
post:
operationId: createPet
responses: { '204': { description: Empty } }
swaggerz generate
warning query/unknown-target features.query.invalidates.createPet: "listPet" is neither a query operation nor a tag; it is ignored.
hint Did you mean "listPets"?

Fix. Name a query operation or a tag; the hint suggests the closest one.

Mocks

mock/invalid-examplewarning

features.mocks: an example or default does not match its schema; the fixture uses a generated value instead

Example: An example its own schema rejects

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Pet:
type: object
properties:
age:
type: integer
minimum: 0
example: -1
swaggerz generate
warning mock/invalid-example The example of `Pet.age` does not match its schema; the fixture uses a generated value instead.
at openapi.yaml:8:5 (#/components/schemas/Pet)
hint Correct the example.

Fix. Correct the example: documentation and fixtures both show it.

mock/unsatisfiablewarning

features.mocks: no generated value satisfies the schema (a model that requires itself, contradictory constraints, never); the fixture may not validate

Example: A model that requires itself

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Node:
type: object
required: [next]
properties:
next:
$ref: '#/components/schemas/Node'
swaggerz generate
warning mock/unsatisfiable `Node` has no finite value: it requires itself, so its fixture cannot be generated.
at openapi.yaml:8:5 (#/components/schemas/Node)

Fix. Make the reference optional or nullable, so that a chain of values can end.

mock/unsupported-patterninfo

features.mocks: no string matching a pattern was found (not a valid ECMAScript pattern, no match within the length bounds, or the matcher's step budget ran out); the fixture does not match it

Example: A pattern no string of the allowed length matches

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
paths: {}
components:
schemas:
Code:
type: string
maxLength: 4
pattern: '^[A-Z]{3}-[0-9]{4}$'
swaggerz generate
info mock/unsupported-pattern No string matching the pattern of `Code` could be generated; the fixture does not match it.
at openapi.yaml:8:5 (#/components/schemas/Code)
hint Add an `example` that matches the pattern.

Fix. Add an example that matches the pattern; the fixture uses it.

Output

output/user-fileerror

A file the generator does not own is in the way, or a directory where a file goes (or a file where a directory goes)

output/edited-stale-filewarning

Hand-edited generated files were kept

output/edited-file-keptwarning

Hand-edited generated files were kept

output/invalid-patherror

A plugin produced an unsafe or duplicate path (not relative and normalized, or containing \, : or empty, . or .. segments)

output/duplicate-patherror

A plugin produced an unsafe or duplicate path (not relative and normalized, or containing \, : or empty, . or .. segments)

output/write-failederror

Writing or deleting failed, or would go through a symbolic link that leaves the output directory. generate leaves the previous output intact; clean deletes nothing when a file is refused

Plugins

plugin/hook-failederror

A plugin hook threw

Dashboard

dashboard/network-accesserror

The dashboard was asked to listen on a non-loopback interface

Internal

internal/errorerror

Unexpected failure; please report it

Lint findings

lint/operation-idwarning

An operation has no operationId: its function name is derived from the method and path and changes with them

Example: An operation without an operationId

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
servers: [{ url: 'https://api.example.com' }]
tags: [{ name: pets }]
paths:
/pets:
post:
summary: Add a pet
tags: [pets]
responses: { '204': { description: Created } }
swaggerz lint
warning lint/operation-id POST /pets has no operationId: its function is named "postPets" after the method and path.
at openapi.yaml:9:5 (#/paths/~1pets/post)
in POST /pets
hint Add an operationId (an overlay can add it to a specification you do not own).

Fix. Add an operationId, so the function keeps its name when the path changes.

lint/operation-id-styleinfo

An operationId is not an identifier in the naming.operations style: the exported function has another name

lint/operation-tagsinfo

An operation has no tags: it is generated into the default group

lint/undeclared-taginfo

A tag used by operations is not declared in the top-level tags

lint/operation-summaryinfo

An operation has neither a summary nor a description for its JSDoc

lint/success-responsewarning

An operation documents no 2xx or default response: it resolves with void

lint/response-schemawarning

A JSON success response has no schema: the operation resolves with unknown

Example: A JSON response without a schema

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
servers: [{ url: 'https://api.example.com' }]
tags: [{ name: pets }]
paths:
/pets:
get:
operationId: listPets
summary: List pets
tags: [pets]
responses:
'200':
description: The pets
content:
application/json: {}
swaggerz lint
warning lint/response-schema The 200 response of GET /pets (application/json) has no schema: "listPets" resolves with unknown.
at openapi.yaml:14:9 (#/paths/~1pets/get/responses/200)
in GET /pets (listPets)

Fix. Describe the body with a schema; until then the function resolves with unknown.

lint/inline-schemainfo

A JSON request or response body is an inline object schema, named after the operation and not reusable

Example: An inline request body

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
servers: [{ url: 'https://api.example.com' }]
tags: [{ name: pets }]
paths:
/pets:
post:
operationId: addPet
summary: Add a pet
tags: [pets]
requestBody:
content:
application/json:
schema:
type: object
properties:
name: { type: string }
responses: { '204': { description: Created } }
swaggerz lint
info lint/inline-schema The request body of POST /pets (application/json) is an inline object schema: its type is named after "addPet" and cannot be reused.
at openapi.yaml:13:7 (#/paths/~1pets/post/requestBody)
in POST /pets (addPet)
hint Move it to components/schemas and reference it.

Fix. Move the schema to components.schemas and reference it, so other operations can share the type.

lint/untyped-schemainfo

A named schema has no type, properties or composition: it is generated as unknown

lint/duplicate-schemainfo

Named schemas are structurally identical: the client contains duplicate types

lint/unused-modelinfo

A named schema is not used by any operation (still generated unless output.models: 'used')

lint/missing-serversinfo

No server is declared and client.baseUrl is not set: the client has no default base URL

Example: No server and no base URL

openapi.yaml
openapi: 3.1.0
info:
title: Example
version: '1.0'
tags: [{ name: pets }]
paths:
/pets:
get:
operationId: listPets
summary: List pets
tags: [pets]
responses: { '204': { description: Empty } }
swaggerz lint
info lint/missing-servers The specification declares no server: the client has no default base URL.
at openapi.yaml
hint Add a server, set client.baseUrl, or call client.setConfig({ baseUrl }) at runtime.

Fix. Declare servers, set client.baseUrl, or call client.setConfig({ baseUrl }) at startup.