Spliceforms · API Governance Rules

Spliceforms API Rules

Spectral linting rules defining API design standards and conventions for Spliceforms.

81 Rules error 46 warn 33
Published by Spliceforms Served by the provider at https://github.com/spliceforms/stoplight-projects/blob/efa3a9d27fea181247794c461dccb33010a2e51d/sf-style-guide/.spectral.json; the copy below was fetched from there.
View Rules File View on GitHub

Rule Categories

api array contact duplicated info license no oas2 oas3 openapi operation parameter path server sf sf_definition sf_inline sf_integer sf_model sf_number sf_object sf_only sf_operation sf_path sf_property sf_query sf_ref sf_request sf_response sf_string tag typed

Rules

error
sf_model-description
**Model description must be present and non-empty string.** - Each Model in your schema must include a `description` field. - The `description` field must be a non-empty string. #### Valid Example ```json "UserProfile": { "type": "object", "description": "Represents a user's profile information.", "properties": { "name": { "type": "string" } } } ``` #### Invalid Example ```json "UserProfile": { "type": "object", "properties": { "name": { "type": "string" } } } ```
#sf_All_Models
warn
sf_operation-summary-formatted
**Operation Summary Rules:** - Must start with an uppercase letter - Must end with a period (dot) #### Valid Examples ```json { "summary": "Get user details." } ``` #### Invalid Examples ```json { "summary": "get user details" } ```
#Operation_Object
error
sf_property-description
**Property description must be present and non-empty string.** - Each Property in your schema must include a `description` field. - The `description` field must be a non-empty string. #### Valid Example ```json "User": { "type": "object", "properties": { "username": { "type": "string", "description": "The username of the user." }, "age": { "type": "integer", "description": "The age of the user." } } } ``` #### Invalid Example ```json "User": { "type": "object", "properties": { "username": { "type": "string", }, "age": { "type": "integer", "description": "" } } } ```
#sf_All_None_Ref_Properties
error
sf_definition-name-upper-camel-case
**Definition names must be in Upper CamelCase:** - Examples of valid names: `Account`, `UserProfile`, `OrderDetails`, `ProductID` - Examples of invalid names: `account`, `userProfile`, `order_details`, `productid` #### Valid Json ```json "Account": { "type": "object", "properties": { "accountNumber": { "type": "string", "description": "Account number." }, } } ``` #### Invalid Json ```json "account": { "type": "object", "properties": { "accountNumber": { "type": "string", "description": "Account number." }, } } ```
#sf_All_Model_Names
error
sf_string-property-example
**String properties must have an `example` field:** Every string property in your schema must include an `example` field to provide sample values. #### Json Example: ```json { "type": "object", "properties": { "username": { "type": "string", "example": "john_doe" }, "email": { "type": "string", "example": "john.doe@example.com" } } }
#sf_All_String_Properties
error
sf_request-header-hyphenated-upper-camel-case
**HTTP Header Fields in request Must Be in Hyphenated-Upper-Camel-Case** HTTP header fields in request parameters should be formatted using Hyphenated-Upper-Camel-Case. This means each word starts with an uppercase letter and is separated by hyphens. #### Valid Examples ```json { "headers": { "X-Api-Key": "123456", "User-Agent": "MyApp/1.0" } } ``` #### Invalid Examples ```json { "headers": { "x-api-key": "123456", // should be "X-Api-Key" "user-agent": "MyApp/1.0" // should be "User-Agent" } } ``
#Request_Parameter_Header
error
sf_string-property-pattern
**The 'Pattern' property must be present and non-empty for string properties** For string properties in your schema, the `Pattern` property must be specified and must not be an empty string. This ensures that the string values conform to the expected format. #### Valid Example ```json { "type": "object", "properties": { "username": { "type": "string", "pattern": "^[a-zA-Z0-9_]+$" } } } ``` #### Invalid Example ```json { "type": "object", "properties": { "username": { "type": "string", "pattern": "" } "email": { "type": "string" } } } ```
#sf_All_String_Properties_Exclude_Enum
error
sf_path-segment-name-lower-camel-case
**Path segments (parameters) must be in lower camel case:** - Path parameters should be written in lower camel case format. This means the first letter should be lowercase, and subsequent words should start with an uppercase letter. - Examples of valid names: `userId`, `orderNumber`, `productCode` - Examples of invalid names: `UserID`, `order_number`, `PRODUCTCODE` #### Valid Example ```json "/users/{userId}": { "get": { "parameters": [ { "name": "userId", "in": "path", "required": true, "schema": { "type": "string" } } ] } } ``` #### Invalid Example ```json "/products/{PRODUCTCODE}": { "get": { "parameters": [ { "name": "PRODUCTCODE", "in": "path", "required": true, "schema": { "type": "string" } } ] } } ```
#Request_Parameter_Path
error
sf_property-name-lower-camel-case
**Property names must be in lower camel case:** - Examples of valid names: `userName`, `orderId`, `productCode` - Examples of invalid names: `UserName`, `order_id`, `ProductCode` #### Json Example: ```json { "userName": "JohnDoe", "orderId": "12345", "productCode": "XYZ789" } ```
#sf_All_Property_Names
error
sf_query-parameter-name-lower-camel-case
**Query parameter names must be in lower camel case:** - Examples of valid names: `userId`, `orderNumber`, `productName` - Examples of invalid names: `UserId`, `order_number`, `ProductName` #### JSON Example: ```json { "parameters": [ { "name": "userId", "in": "query", "required": true, "schema": { "type": "string" } }, { "name": "orderNumber", "in": "query", "required": true, "schema": { "type": "string" } } ] } ```
#Request_Parameter_Query
error
sf_response-header-hyphenated-upper-camel-case
**HTTP Header Fields in Response Must Be in Hyphenated-Upper-Camel-Case** HTTP header fields in response parameters should be formatted using Hyphenated-Upper-Camel-Case. This means each word starts with an uppercase letter and is separated by hyphens. #### Valid Examples ```json { "headers": { "X-Api-Key": "123456" } } ``` #### Invalid Examples ```json { "headers": { "x-api-key": "123456" // should be "X-Api-Key" } } ``
#sf_All_Response_Header_Names
error
sf_definition-type
**Model Definitions must have a type** All model definitions must include a `type` property to specify the type of the model. #### JSON Example: ```json "User": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" } } } ```
#sf_All_Models
error
sf_integer-property-min-max
**An integer property must include minimum and maximum constraints but must not have exclusiveMinimum or exclusiveMaximum constraints.** Every integer property in your schema must include the following constraints: - `minimum`: The minimum value the integer can take. - `maximum`: The maximum value the integer can take. #### Json Example: ```json { "type": "object", "properties": { "age": { "type": "integer", "minimum": 0, "maximum": 100, "exclusiveMinimum": false, "exclusiveMaximum": false }, "score": { "type": "integer", "minimum": 1, "maximum": 10, "exclusiveMinimum": false, "exclusiveMaximum": false } } }
#sf_All_Integer_Properties
error
sf_property-format-for-integer
**Integer properties must have a format and should be either `int32` or `int64`:** **Formats:** - `int32`: A 32-bit signed integer. - `int64`: A 64-bit signed integer. #### Valid Examples ```json { "exampleInt32": { "type": "integer", "format": "int32" }, "exampleInt64": { "type": "integer", "format": "int64" } } ``` #### Invalid Examples ```json { "exampleIntInvalid": { "type": "integer", "format": "int16" }, "anotherInvalidInt": { "type": "integer" } } ```
#sf_All_Integer_Properties
error
sf_property-format-for-number
**Rule: The "Number" type of properties should not have a format attribute.** All numbers are considered in the `BigDecimal` format. #### Valid JSON ```json { "example": { "type": "number" // No format attribute present. } } ``` #### Invalid JSON ```json { "example": { "type": "number", "format": "float" // Invalid: Number properties should not have a format attribute. } } ```
#sf_All_Number_Properties
error
sf_property-type
**Property must have a type** - Every property in your schema must have a defined type. #### Valid Examples ```json { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "required": ["name", "age"] } ``` #### Invalid Examples ```json { "type": "object", "properties": { "name": { "type": "string" }, "age": { } }, "required": ["name", "age"] } ```
#sf_All_None_Ref_Properties
error
sf_string-property-min-max
**`minLength` and `maxLength` constraints must be present for string properties.** All string properties must have both `minLength` and `maxLength` constraints defined. This ensures that the length of the string values is appropriately restricted. #### Valid Examples ```json { "type": "object", "properties": { "username": { "type": "string", "minLength": 3, "maxLength": 20 }, "password": { "type": "string", "minLength": 8, "maxLength": 50 } } } ``` #### Invalid Examples ```json { "type": "object", "properties": { "username": { "type": "string", "maxLength": 20 }, "password": { "type": "string" } } } ```
#sf_All_String_Properties_Exclude_Enum
error
sf_inline-model-ref
**Model must not contain another model inline. `#Ref` property should be used instead.** In OpenAPI definitions, models should not contain other models directly inline. Instead, use the `$ref` property to reference other models. #### Json Example ```json { "components": { "schemas": { "User": { "type": "object", "properties": { "id": { "type": "string" }, "profile": { "$ref": "#/components/schemas/Profile" } } }, "Profile": { "type": "object", "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } } } } } }
#sf_All_Object_Properties
error
sf_only-local-references
**Only local schema references must be used.** All schema references should be local to the current document. External schema references are not allowed. #### Valid Example ```json { "$ref": "#/components/schemas/User" } ``` #### Invalid Example ```json { "$ref": "https://example.com/schemas/User" } ```
#sf_all_ref
error
sf_number-property-example
**Number property must have an `example`:** Each number property in your JSON schema must include an `example` field to provide a sample value. This ensures better documentation and understanding of the expected data format. #### Json Example ```json { "type": "object", "properties": { "age": { "type": "number", "description": "The age of the person", "example": 30 }, "price": { "type": "number", "description": "The price of the item", "example": 99.99 } }, "required": ["age", "price"] }
#sf_All_Number_Properties
error
sf_integer-property-example
**Integer property must have an `example`.** Each integer property in your API specification must include an `example` field to ensure clarity and consistency. #### Example JSON ```json { "type": "object", "properties": { "age": { "type": "integer", "example": 30 } } } ``` #### Valid Example ```json { "type": "integer", "example": 123 } ``` #### Invalid Example ```json { "type": "integer" } ```
#sf_All_Integer_Properties
warn
sf_model-required-field
This rule ensures that an object model in your OpenAPI specification has at least one required field. Additionally, the specified required fields must be present in the `properties` of the object model. #### Valid Json ```json { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "required": ["name"] } ``` #### Valid Json ```json { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["age"] } ```
#sf_All_Model_Required_Field
error
sf_response-4XX-5XX-json-problem
This rule ensures that all API responses with status codes in the 4XX or 5XX range (client and server errors) must return a ProblemJson model. #### Valid json ```json { "paths": { "/example": { "get": { "responses": { "500": { "description": "Internal Server Error", "content": { "application/json": { "schema": { "type": "object", "required": ["type", "title", "status"], "properties": { "type": { "type": "string", "example": "https://example.com/error" }, "title": { "type": "string", "example": "Internal Server Error" }, "status": { "type": "integer", "format": "int32", "example": 500 }, "detail": { "type": "string", "example": "An unexpected error occurred." }, "instance": { "type": "string", "example": "/example/123" } } } } } } } } } } } ``` #### Invalid json ```json { "paths": { "/example": { "get": { "responses": { "500": { "description": "Internal Server Error" // Missing content.application/json } } } } } } { "paths": { "/example": { "get": { "responses": { "500": { "description": "Internal Server Error", "content": { "application/json": { "schema": { "type": "object", "required": ["type", "title", "status"], "properties": { "type": { "type": "string", "example": "https://example.com/error" }, "title": { "type": "integer", // Invalid type, should be string "example": 123 }, "status": { "type": "string", // Invalid type, should be integer "example": "500" } } } } } } } } } } } ```
#sf_Response_4XX-5XX_Ref
error
sf_string-property-enum-check
This rule validates that if a string property with an `enum` in a schema specifies `pattern`, `minLength`, or `maxLength`, the `enum` values must conform to these constraints. #### Valid Example ```json { "components": { "schemas": { "ExampleSchema": { "type": "object", "properties": { "validStringProperty": { "type": "string", "enum": [ "ABC123", "DEF456" ], "pattern": "^[A-Z]{3}\\d{3}$", "minLength": 6, "maxLength": 6 } } } } } } ``` #### Invalid Example ```json { "components": { "schemas": { "ExampleSchema": { "type": "object", "properties": { "invalidStringPropertyMinLength": { "type": "string", "enum": [ "A1", "B2" ], "pattern": "^[A-Z]\\d$", "minLength": 3, "maxLength": 3 } } } } } } ```
#sf_All_Enum
error
sf-model-array-items-object-properties
This rule ensures that array items do not have an inline object definition. Instead, array items should refer to a defined object using `$ref`. #### Valid Json ```json { "components": { "schemas": { "MyArrayModel": { "type": "array", "items": { "$ref": "#/components/schemas/MyObjectModel" } }, "MyObjectModel": { "type": "object", "properties": { "id": { "type": "string" } } } } } } ``` #### Invalid Json ```json { "components": { "schemas": { "MyArrayModel": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" } } } } } } } ```
#sf_All_Array_Items_Properties
error
sf_object-model-properties-required
This rule ensures that object model definitions include a properties field and that this field contains at least one property. #### Valid Json ```json { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } } } ``` #### Invalid Json ```json { "type": "object" } ``` ```json { "type": "object", "properties": {} } ```
#sf_Object_Properties
error
sf_response-schema-json-object
Ensure that response schemas do not return primitive types (array, string, integer, number) directly. Instead, these types should be wrapped inside an object. #### Valid Json ```json { "type": "object", "properties": { "data": { "type": "string" } } } ``` #### Invalid Json ```json { "type": "string" } ```
#sf_All_Response_Schemas
error
sf_string-date-property
If a string property has a format of `date` or `date-time`, and `minLength` and `maxLength` are specified, they should correctly reflect the length of a valid date or date-time string. #### valid Json ```json { "type": "object", "properties": { "endDate": { "type": "string", "format": "date", "minLength": 10, "maxLength": 10, "example": "2023-08-18" } } } ``` #### Invalid Json ```json { "type": "object", "properties": { "endDate": { "type": "string", "format": "date", "minLength": 5, // Invalid, should match length of a valid date string "maxLength": 20, // Invalid, should match length of a valid date string "example": "2023-08-18" } } } ```
#sf_All_Date_Properties
off
sf_problem_json_required_field
The ProblemJson model must exist within the OpenAPI specification and include the following required properties and json payload: - type - title - status #### Valid Json Example ```json "ProblemJson": { "title": "ProblemJson", "description": "This schema defines a structured problem details", "x-stoplight": { "id": "xmrewz8ybd807" }, "type": "object", "required": [ "type", "title", "status" ], "properties": { "type": { "type": "string", "format": "uri", "description": "A URI reference that identifies the problem type. This specification encourages that, when dereferenced, it provides human-readable documentation for the problem type.", "example": "https://example.com/probs/out-of-credit", "minLength": 10, "maxLength": 2048, "pattern": "^(https?|ftp):\\/\\/[^\\s/$.?#].[^\\s]*$" }, "title": { "type": "string", "description": "A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.", "example": "Insufficient credit", "minLength": 1, "maxLength": 256, "pattern": "^[\\w\\s-]+$" }, "status": { "type": "integer", "format": "int32", "description": "The HTTP status code generated by the origin server for this occurrence of the problem.", "example": 400, "minimum": 400, "maximum": 599, "exclusiveMinimum": false, "exclusiveMaximum": false }, "detail": { "type": "string", "description": "A human-readable explanation specific to this occurrence of the problem.", "example": "Your account balance is too low to complete this transaction.", "minLength": 1, "maxLength": 1024, "pattern": "^[\\w\\s,.-]+$" }, "instance": { "type": "string", "format": "uri", "description": "A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.", "example": "https://example.com/account/12345/transactions/abc", "minLength": 10, "maxLength": 2048, "pattern": "^(https?|ftp):\\/\\/[^\\s/$.?#].[^\\s]*$" } } } ```
#sf_Problem_Json_Model
error
json_check
#sf_Response_4XX-5XX_Ref
error
sf_enum_no_whitespace
#All_Enum_Value
error
sf_ref-properties-must-have-description
Properties with $ref must also have a description field to provide context about the referenced schema's usage in this specific context.
#sf_All_Ref_Properties
warn
contact-url
The `contact` object should have a valid organization URL. **Valid Example** ```json lineNumbers { "contact": { ... , "url": "https://acme.com", ... }, ```
#API_Contact
warn
contact-email
The `contact` object should have a valid email. **Valid Example** ```json lineNumbers { "contact": { ... , ... , "email": "support.contact@acme.com" }, ```
#API_Contact
warn
info-contact
The `info' object should include a `contact` object. **Valid Example** ```json lineNumbers { "info": { ... , ... , "contact": { "name": "ACME Corporation", "url": "https://acme.com", "email": "support.contact@acme.com" } } } ```
#API_Document
error
info-description
The `info` object should have a `description` object. **Valid Example** ```json lineNumbers { "info": { ... , ... , "description": "This describes my API.", ... } } } ```
#API_Document
warn
info-license
The `info` object should have a `license` object. **Valid Example** ```json lineNumbers { "info": { ... , ... , "license": { "name": "Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)", "url": "https://creativecommons.org/licenses/by-sa/4.0/" } } } ```
#API_Document
warn
license-url
The `license` object should include a valid url. **Valid Example** ```json lineNumbers { "license": { "name": "Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)", "url": "https://creativecommons.org/licenses/by-sa/4.0/" } } ```
#API_License
warn
no-eval-in-markdown
Markdown descriptions should not contain [`eval()` functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval), which pose a security risk. **Invalid Example** ```json lineNumbers { "info": { ... , ... , "description": "API for users. eval()"
#All_Markdown
warn
no-script-tags-in-markdown
Markdown descriptions should not contain `script` tags, which pose a security risk. **Invalid Example** ```json lineNumbers { "info": { ... , ... , "description": "API for users. '," ```
#All_Markdown
warn
openapi-tags-alphabetical
Global tags specified at the root OpenAPI Document level should be in alphabetical order based on the `name` property. **Invalid Example** ```json lineNumbers { "tags":[ { "name":"Z Global Tag" }, { "name":"A Global Tag" } ] } ``` **Valid Example** ```json lineNumbers { "tags":[ { "name":"A Global Tag" }, { "name":"Z Global Tag" } ] } ```
#API_Document
warn
openapi-tags
At least one global tag should be specified at the root OpenAPI Document level. **Valid Example** ```json lineNumbers { "tags":[ { "name":"Global Tag #1" }, { "name":"Global Tag #2" } ] } ```
#API_Document
warn
operation-description
Each operation should have a description. **Valid Example** ```json lineNumbers { "get": { ... , "description": "Get a list of users.", ... , ... , } } ```
#Operation_Object
warn
operation-operationId
All operations should have an `operationId`. **Valid Example** ```json lineNumbers { "get": { "summary": "Get users", ... , "operationId": "get-users" } } ```
#Operation_Object
error
operation-operationId-valid-in-url
Operation IDs must not contain characters that are invalid for URLs. **Invalid Example** The `operationId` in this example includes a pipe and space, which are invalid for URLs. ```json lineNumbers { "/users": { "get": { ... , "operationId": "invalid|operationID ", ... , } } } ``` **Valid Example** This `operationId` is valid for URLs. ```json lineNumbers { "/users": { "get": { ... , "operationId": "this-must-be-unique", ... , } } } ```
#Operation_Object
off
operation-singular-tag
Operation should not have more than a single tag.
#API_Tags
warn
operation-tags
At least one tag should be defined for each operation. **Valid Example** ```json lineNumbers { "get": { ... , ... , "tags": [ "Users" ], } }
#Operation_Object
error
path-declarations-must-exist
Path parameter declarations must not be empty. **Invalid Example** `/users/{}` **Valid Example** `/users/{userId}`
#Path_Item
warn
contact-name
The `contact` object should have an organization name. **Valid Example** ```json lineNumbers { "contact": { "name": "ACME Corporation", ... , ... }, ```
#API_Contact
warn
path-keys-no-trailing-slash
Path keys should not end in forward slashes. This is a best practice for working with web tooling, such as mock servers, code generators, application frameworks, and more). **Invalid Example** ```json { "/users/": { ``` **Valid Example** ```json { "/users": { ```
#Path_Object
warn
path-not-include-query
Paths should not include `query` string items. Instead, add them as parameters with `in: query`. **Invalid Example** ```json { "/users/{?id}": { ``` **Valid Example** ```json lineNumbers { "parameters": [ { "schema": { "type": "string" }, "name": "id", "in": "path", "required": true, "description": "User's ID" } ] } ```
#Path_Object
warn
tag-description
Tags defined at the global level should have a description. **Valid Example** ```json lineNumbers { "tags": [ { "name":"Users", "description":"End-user information" } ] } ```
#API_Tags_Item
warn
api-servers
A server should be defined at the root document level. This can be localhost, a development server, or a production server. **Valid OpenAPI V3 Example** ```json { "servers": [ { "url": "https://staging.myprodserver.com/v1", "description": "Staging server" }, { "url": "https://myprodserver.com/v1", "description": "Production server" } ] } ``` **Valid OpenAPI V2 Example** ```json { "host": "myprodserver.com", "basePath": "/v2", "schemes": [ "https" ] } ```
#API_Server
warn
server-trailing-slash
Server URLs should not end in forward slashes. This is a best practice for working with web tooling, such as mock servers, code generators, application frameworks, and more). **Invalid Example** ```json lineNumbers { "servers": [ { ... , "url": "https://api.openweathermap.org/data/2.5/" } ] } ``` **Valid Example** ```json lineNumbers { "servers": [ { ... , "url": "https://api.openweathermap.org/data/2.5" } ] } ```
#API_Server_URL
warn
operation-success-response
Operations should have at least one "2xx" or "3xx" response defined. **Invalid Example** ```json lineNumbers { "get": { ... , "responses": {}, } } ``` **Valid Example** ```json lineNumbers { "get": { ... , "responses": { "200": { "description": "OK" } }, } } ```
#Operation_Object
error
path-params
Path parameters must be defined and valid in either the `path-parameters` or the `operation-parameters` object. Likewise, defined `path-parameters` or `operation-parameters` must be used in the `paths` string. **Valid Example** For this path: `/users/{id}/{location}` The following path parameters must be defined. ```json lineNumbers "parameters": [ { "schema": { "type": "string" }, "name": "id", "in": "path", "required": true, "description": "This is the user's ID" }, { "schema": { "type": "string" }, "name": "location", "in": "path", "required": true, "description": "This is the user's location" } ] } }, ```
#API_Document
warn
operation-parameters
Operation parameters should be unique and non-repeating: * `name` and `in` must be unique For OAS2: * Operations should not have `in: body` and `in: formData` parameters. * Operations should have only one `in: body` parameter. **Invalid Example** In this example, the query paramater `"name": "last name"` is repeated. ```json lineNumbers { "parameters": [ { "schema": { "type": "string" }, "in": "query", "name": "last name", "description": "User's last name" }, { "schema": { "type": "string" }, "in": "query", "name": "last name", "description": "User's last name" } ], } ``` **Valid Example** In this example, query parameters are unique. ```json lineNumbers { "parameters": [ { "schema": { "type": "string" }, "in": "query", "name": "first name", "description": "User's first name" }, { "schema": { "type": "string" }, "in": "query", "name": "last name", "description": "User's last name" } ], } ```
#Operation_Object
warn
typed-enum
All `enum' values should respect the specified type. **Invalid Example** In this example, the `enum` type is `integer`, but the values are strings. ```json lineNumbers { "schema": { "type": "integer", "enum": [ "standard", "metric", "imperial" ] }, ``` **Valid Example** In this example, the `enum` type is `string` and the values are strings. ```json lineNumbers { "schema": { "type": "string", "enum": [ "standard", "metric", "imperial" ] },
$..[?(@ && @.enum && @.type)]
error
oas2-schema
This Stoplight core rule validates the structure of OpenAPI v2 specification. This rule should never be disabled.
#API_Document
error
oas3-schema
This Stoplight core rule validates the structure of OpenAPI v3.x specification. This rule should never be disabled.
#API_Document
warn
oas3-unused-component
A potentially shareable component is not being used. This may be expected, but you should review sharable components to avoid duplicate entry.
#API_Document
error
operation-operationId-unique
Every operation in a single document must have a unique `operationID`. **Valid Example** In this example, the `operationId` is `get-users`. This `operationId` must be unique in an API document. ```json lineNumbers { "get": { "summary": "Get users", ... , "operationId": "get-users" } } ```
#API_Document
error
oas2-operation-formData-consume-check
Operations with an `in: formData` parameter must include a `consumes` property with one of these values: `application/x-www-form-urlencoded` `multipart/form-data` **Valid Example** In this example, the `consumes` property correctly includes the `multipart/form-data` value. ```json lineNumbers { "post":{ "summary":"Uploads a file", "consumes":[ "multipart/form-data" ], "parameters":[ { "name":"name", "in":"formData", "description":"Upload a file", "required":false, "type":"string" } ] } }
#Operation_Object
warn
operation-tag-defined
Tags defined at the operation level should also be defined at the global level. **Operation-level Example** ```json lineNumbers { "get": { ... , ... , "tags": [ "Users" ], } } ``` **Global-level Example** ```json lineNumbers { "tags": [ { "name": "Users", ... , } ], } ```
#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 global `securityDefinitions` object. Empty `security` values for operations are ignored if authentication is not explicity required or is optional. **Valid Example** For this global security scheme: ```json lineNumbers { "securityDefinitions": { "API Key": { "name": "API Key", "type": "apiKey", "in": "query" } } } ``` This is a valid operation security value: ```json lineNumbers { "operationId": "get-users-userId", "security": [ { "API Key": [] } ] } ``` **Invalid Example** For the same global security scheme, this is an invalid operation security value: ```json lineNumbers { "operationId": "get-users-userId", "security": [ { "oath2": [] } ] } ```
#API_Document
warn
oas3-operation-security-defined
Operation `security` values must match a scheme defined in the global `components.security.Schemes` object. **Valid Example** For this global security scheme: ```json lineNumbers { "components": { "security": [ { "app-id": [] } ] } } ``` `app-id` is a valid operation `security` value: ```json lineNumbers { "get": { "security": [ { "app-id": [] } ] } } ``` **Invalid Example** For the same global security scheme, `oath2` is an invalid operation `security` value: ```json lineNumbers { "get": { "security": [ { "oath2": [] } ] } } ```
#API_Document
warn
duplicated-entry-in-enum
All enum values should be unique. **Invalid Example** There are two `json` enum values. ```json lineNumbers { "schema":{ "type":"string", "enum":[ "json", "json", "html" ] } } ``` **Valid Example** All enum values are unique. ```json lineNumbers { "schema":{ "type":"string", "enum":[ "json", "xml", "html" ] } } ```
#All_Enum_Object
error
oas2-api-schemes
OpenAPI 2 host `schemes` reflect the transfer protocol of the API. Host schemes must be present and an array with one or more of these values: `http`, `https`, `ws`, or `wss`. **Valid Example** This example shows that host schemes are `http` and `https`. ```json { "schemes":[ "http", "https" ] } ```
#API_Document
error
oas2-discriminator
Discriminator property must be defined and required
#API_Document
warn
server-not-example
Server URLs must not direct to example.com. This helps ensure URLs are valid before you distribute your API document. **Invalid Example** ```json lineNumbers { "servers": [ { ... , "url": "https://example.com" } ] } ``` **Valid Example** ```json lineNumbers { "servers": [ { ... , "url": "https://api.openweathermap.org/data/2.5" } ] } ```
#API_Server_URL
warn
parameter-description
All `parameter` objects should have a description. **Valid Example** ```json lineNumbers { "parameters": [ { "schema": { "type": "integer" }, ... , ... , "description": "The number of days to include in the response." } } ```
#Request_Parameter_All
warn
oas2-anyOf
The `anyOf` keyword is not supported in OAS2. Only `allOf` is supported. **Invalid Example** ```json lineNumbers { "schema": { "anyOf": [ { "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } } }, {} ], } } ``` **Valid Example** ```json lineNumbers { "schema": { "type": "object", "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } }, } } ```
#API_Document_RecursiveSearch
warn
oas2-oneOf
The `oneOf` keyword is not supported in OAS2. Only `allOf` is supported. **Invalid Example** ```json lineNumbers { "schema": { "oneOf": [ { "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } } }, {} ], } } ``` **Valid Example** ```json lineNumbers { "schema": { "type": "object", "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } }, } } ```
#API_Document_RecursiveSearch
warn
oas3-examples-value-or-externalValue
The `examples` object should include a `value` or `externalValue` field, but cannot include both. **Invalid Example** This example includes both a `value` field and an `externalValue` field. ```json lineNumbers { "examples": { "example-1": { "value": { "id": "string", "name": "string" }, "externalValue": { "id": "string", "name": "string" } } } } ``` **Valid Example** This example includes only a `value` field. ```json lineNumbers { "examples": { "example-1": { "value": { "id": "string", "name": "string" } } } }
#All_Example
error
oas2-valid-schema-example
Examples must be valid against their defined schema. **Valid Example** The following schema includes the `name` and `petType` properties. ```json lineNumbers { "Pet":{ "type":"object", "properties":{ "name":{ "type":"string" }, "petType":{ "type":"string" } } } } ``` When referenced in a response example, the property names on line 6 and 7 must match those in the schema (`petName` and `petType`). ```json lineNumbers { "responses":{ "200":{ "content":{ "application/json":{ "examples":{ "Pet Example":{ "petName":"Bubbles", "petType":"Dog" } }, "schema":{ "$ref":"#/definitions/Pet" } } } } } } ```
#All_Example_Schema
error
oas3-valid-schema-example
Examples must be valid against their defined schema. **Valid Example** The following schema includes the `name` and `petType` properties. ```json lineNumbers { "Pet":{ "type":"object", "properties":{ "name":{ "type":"string" }, "petType":{ "type":"string" } } } } ``` When referenced in a response example, the property names on line 6 and 7 must match those in the schema (`petName` and `petType`). ```json lineNumbers { "responses":{ "200":{ "content":{ "application/json":{ "examples":{ "Pet Example":{ "petName":"Bubbles", "petType":"Dog" } }, "schema":{ "$ref":"#/definitions/Pet" } } } } } } ```
#All_Example_Schema
error
oas2-valid-media-example
Examples must be valid against their defined schema. Common reasons you may see errors if: * The value used for property examples is not the same type indicated in the schema (string vs. integer, for example). * Examples contain properties not included in the schema. **Valid Example** The following schema indicates that the `id` property is a `string` type. ```json lineNumbers "User":{ "title":"User", "type":"object", "properties":{ "id":{ "type":"string" } } } ``` When the example is referenced in a response, the `id` property must be `string`. ```json lineNumbers { "responses":{ "200":{ "description":"User Found", "schema":{ "$ref":"#/definitions/User" }, "examples":{ "Get User Alice Smith":{ "id": "smith, alice", } } }, ```
#All_Example_Media
error
oas3-valid-media-example
The following schema includes the `name` and `petType` properties. **Valid Example** ```json lineNumbers { "Pet":{ "type":"object", "properties":{ "name":{ "type":"string" }, "petType":{ "type":"string" } } } } ``` When referenced in a response example, the property names on line 6 and 7 must match those in the schema (`petName` and `petType`). ```json lineNumbers { "responses":{ "200":{ "content":{ "application/json":{ "examples":{ "Pet Example":{ "petName":"Bubbles", "petType":"Dog" } }, "schema":{ "$ref":"#/definitions/Pet" } } } } } } ```
#All_Example_Media
error
oas3-server-variables
This rule ensures that server variables defined in OpenAPI Specification 3 (OAS3) and 3.1 are valid, not unused, and result in a valid URL. Properly defining and using server variables is crucial for the accurate representation of API endpoints and preventing potential misconfigurations or security issues. **Recommended**: Yes **Bad Examples** 1. **Missing definition for a URL variable**: ```yaml servers: - url: "https://api.{region}.example.com/v1" variables: version: default: "v1" ``` In this example, the variable **`{region}`** in the URL is not defined within the **`variables`** object. 2. **Unused URL variable:** ```yaml servers: - url: "https://api.example.com/v1" variables: region: default: "us-west" ``` Here, the variable **`region`** is defined but not used in the server URL. 3. **Invalid default value for an allowed value variable**: ```yaml servers: - url: "https://api.{region}.example.com/v1" variables: region: default: "us-south" enum: - "us-west" - "us-east" ``` The default value 'us-south' isn't one of the allowed values in the **`enum`**. 4. **Invalid resultant URL**: ```yaml servers: - url: "https://api.example.com:{port}/v1" variables: port: default: "8o80" ``` Substituting the default value of **`{port}`** results in an invalid URL. **Good Example** ```yaml servers: - url: "https://api.{region}.example.com/{version}" variables: region: default: "us-west" enum: - "us-west" - "us-east" version: default: "v1" ``` In this example, both **`{region}`** and **`{version}`** variables are properly defined and used in the server URL. Also, the default value for **`region`** is within the allowed values.
#All_Servers
error
array-items
Schemas with `type: array`, require a sibling `items` field. **Recommended:** Yes **Good Example** ```yaml TheGoodModel: type: object properties: favoriteColorSets: type: array items: type: array items: {} ``` **Bad Example** ```yaml TheBadModel: type: object properties: favoriteColorSets: type: array items: type: array ```
#All_Array_Item

Spectral Ruleset

Raw ↑
# harvested from https://github.com/spliceforms/stoplight-projects/blob/efa3a9d27fea181247794c461dccb33010a2e51d/sf-style-guide/.spectral.json on 2026-10-09 — a Spectral ruleset published in the provider's own GitHub repository (spliceforms/stoplight-projects); found by GitHub code search, fetched verbatim and converted from JSON to YAML
x-method: harvested
x-stamped: 2026-10-09
x-source-url: https://github.com/spliceforms/stoplight-projects/blob/efa3a9d27fea181247794c461dccb33010a2e51d/sf-style-guide/.spectral.json
description: ''
formats:
- oas2
- oas3
- oas3.0


# --- truncated at 32 KB (87 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/spliceforms/refs/heads/main/rules/spliceforms-stoplight-projects-spectral-rules.yml

Work with this as data

Every ruleset here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for spectral rules

4 MCP tools reach this
  • find_rulesBrowse and filter every ruleset in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/spliceforms-stoplight-projects-spectral-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.