Stoplight · API Governance Rules
Stoplight — spectral action rules
Spectral linting rules defining API design standards and conventions for Stoplight.
47 Rules
error 14
warn 32
Published by Stoplight
Served by the provider at https://github.com/stoplightio/spectral-action/blob/6416fd018ae38e60136775066eb3e98172143141/.spectral.json; the copy below was fetched from there.
Rule Categories
api
contact
duplicated
info
license
no
oas2
oas3
openapi
operation
parameter
path
server
tag
typed
Rules
warn
contact-url
Contact object should have "url"
#API_Contact
warn
contact-email
Contact object should have "email"
#API_Contact
warn
info-contact
Info object should have "contact" object.
#API_Document
warn
info-description
Info object should have "description" object.
#API_Document
warn
info-license
Info object should have "license" object.
#API_Document
warn
license-url
License object should include "url".
#API_License
warn
no-eval-in-markdown
Markdown descriptions must not have "eval(".
#All_Markdown
warn
no-script-tags-in-markdown
Markdown descriptions must not have "eval(".
#All_Markdown
warn
openapi-tags-alphabetical
OpenAPI object should have alphabetical "tags".
#API_Tags
warn
openapi-tags
OpenAPI object should have non-empty "tags" array.
#API_Tags
warn
operation-description
Operation "description" should be present and non-empty string.
#Operation_Object
warn
operation-operationId
Operation should have "operationId".
#Operation_Object
error
operation-operationId-valid-in-url
operationId must not characters that are invalid when used in URL.
#Operation_Object
off
operation-singular-tag
Operation should not have more than a single tag.
#API_Tags
warn
operation-tags
Operation should have non-empty "tags" array.
#Operation_Object
error
path-declarations-must-exist
Path parameter declarations must not be empty, ex.`/given/{}` is invalid.
#Path_Item
warn
contact-name
Contact object should have "name"
#API_Contact
warn
path-keys-no-trailing-slash
Path should not end with slash.
#Path_Object
warn
path-not-include-query
Path should not include query string.
#Path_Object
warn
tag-description
Tag object should have `description`.
#API_Tags_Item
warn
api-servers
OpenAPI document should have a server defined. This can be localhost, a development or production server. **OpenAPI V3 example** ```json { "servers": [ { "url": "https://staging.myprodserver.com/v1", "description": "Staging server" }, { "url": "https://myprodserver.com/v1", "description": "Production server" } ] } ``` **OpenAPI V2 example** ```json { "host": "myprodserver.com", "basePath": "/v2", "schemes": [ "https" ] } ```
#API_Server
warn
server-trailing-slash
Server URL should not have trailing slash.
#API_Server_URL
warn
operation-success-response
Operation should have at least one "2xx" or "3xx" response.
#Operation_Object
error
path-params
Path parameters must be defined and valid.
#API_Document
warn
operation-parameters
Operation parameters are unique and non-repeating.
#Operation_Object
warn
typed-enum
Enum values should respect the specified type.
#All_Enum
error
oas2-schema
Validate structure of OpenAPI v2 specification.
#API_Document
error
oas3-schema
Validate structure of OpenAPI v3 specification.
#API_Document
warn
oas3-unused-component
Validate structure of OpenAPI v3 specification.
#API_Document
error
operation-operationId-unique
Every operation must have unique operationId.
#API_Document
error
oas2-operation-formData-consume-check
Operations with "in: formData" parameter must include "application/x-www-form-urlencoded" or "multipart/form-data" in their "consumes" property.
#Operation_Object
warn
operation-tag-defined
Operation tags must be defined in global tags.
#API_Document
error
no-$ref-siblings
Property must not be placed among $ref
#All_Ref
warn
oas2-operation-security-defined
Operation "security" values must match a scheme defined in the "securityDefinitions" object.
#API_Document
warn
oas3-operation-security-defined
Operation `security` values must match a scheme defined in the `components.securitySchemes` object.
#API_Document
warn
duplicated-entry-in-enum
Enum values should not have duplicate entry.
#All_Enum
error
oas2-api-schemes
OpenAPI host "schemes" must be present and non-empty array.
#API_Document
error
oas2-discriminator
Discriminator property must be defined and required
#API_Document
warn
server-not-example
#API_Server_URL
warn
parameter-description
#Request_Parameter_All
warn
oas2-anyOf
anyOf is not available in OpenAPI v2, it was added in OpenAPI v3
#API_Document_RecursiveSearch
warn
oas2-oneOf
anyOf is not available in OpenAPI v2, it was added in OpenAPI v3
#API_Document_RecursiveSearch
warn
oas3-examples-value-or-externalValue
Examples must have either "value" or "externalValue" field.
#All_Example
error
oas2-valid-schema-example
Examples must be valid against their defined schema.
#All_Example_Schema
error
oas3-valid-schema-example
Examples must be valid against their defined schema.
#All_Example_Schema
error
oas2-valid-media-example
Examples must be valid against their defined schema.
#All_Example_Media
error
oas3-valid-media-example
Examples must be valid against their defined schema.
#All_Example_Media
Spectral Ruleset
Work with this as data
Every ruleset here is available over the APIs.io API and to AI agents over MCP.