OpenAPI errors and their fixes
The message a linter, validator or mock server prints, the spec that causes it, and the fix. Each page comes with the output of the tools that read the example, and says when it was last checked.
- "Every operation must have unique operationId" (operation-operationId-unique)
Two operations share an operationId. The specification requires ids to be unique across the whole API; tools may use them to identify an operation, and some SDK generators turn them into method names. How to find the pair, and a naming scheme that does not collide.
- "invalid-ref ... does not exist" and "Can't resolve $ref": finding a broken reference
An OpenAPI $ref that points to nothing. How a linter and a bundler report it, how to read the path in the message, and the five usual causes: a typo, the wrong section, a moved file, a missing escape, a case difference.
- "must be equal to constant": a value that const does not allow
The schema fixes a property to one value with const, and the payload has another. Usually the discriminating field of a oneOf variant. How to find the expected value, and why the error often points at a variant you did not mean.
- "must be equal to one of the allowed values": an enum mismatch
The value is not in the schema's enum. The four usual reasons: a new value the description does not list yet, a difference in case, null missing from the enum, and a number sent as a string.
- "must be string", "must be integer": a value of the wrong type
The value's JSON type differs from the schema's type. Numbers in quotes, 1.5 for an integer, null for a non-nullable field, and why query parameters behave differently from a JSON body. With a mock server's answers.
- "must have required property": which property, where, and why
The payload lacks a property that the schema lists under required. How to read the pointer, why it appears in bulk under oneOf and anyOf, and the cases where the schema is wrong: readOnly fields and required with null.
- "must match exactly one schema in oneOf": what it means and how to fix it
The validator found that a value fits none of the oneOf schemas, or more than one. How to tell the two cases apart from the error list, and the three fixes: required, const and additionalProperties.
- "must NOT have additional properties": why a request is refused
The schema sets additionalProperties: false and the payload has a property it does not list. How to find which one, when the schema is wrong and not the payload, and the allOf combination that refuses every payload.
- "Operation must define parameter {id} as expected by path" (path-params)
A path contains {name} and the operation does not declare a path parameter of that name, or declares one the path does not contain, or forgets required: true. The four messages you usually see and the fix for each.
- "Operation must have non-empty "tags" array" (operation-tags)
A linter found an operation with no tags key or with tags: []. The document is valid in OpenAPI 3.0 and 3.1; the Spectral rule operation-tags warns because tags group operations in documentation. Add one tag per operation, or set the rule to off.
- "Potentially unused component has been detected" (oas3-unused-component)
A linter found a schema, parameter or response under components that nothing refers to. Why it is a warning, the three real causes (a leftover, a typo in a $ref, a component used from another file), and how to switch the rule off.
Try it with your own API
Create a free workspace, add your API files, and publish their documentation and a mock server from the same repository.
Free for individuals. No credit card.
$ npm install -g @apigit/cli$ apigit auth login$ apigit doc publish