All Spectral rules used in the IPA validation are defined in rulesets grouped by IPA number (IPA-XXX.yaml
). These rulesets are imported into the main IPA ruleset ipa-spectral.yaml which is used for running the validation.
Below is a list of all available rules, their descriptions and severity levels.
Rules are based on http://go/ipa/IPA-5.
IPA exception extensions must follow the correct format.
Rule checks for the following conditions:
- Exception rule names must start with 'xgen-IPA-' prefix
- Each exception must include a non-empty reason as a string
- This rule itself does not allow exceptions
Rules are based on http://go/ipa/IPA-102.
Collection identifiers must be in camelCase.
Rule checks for the following conditions:
- All path segments that are not path parameters
- Only the resource identifier part before any colon in custom method paths (e.g.,
resource
in/resource:customMethod
) - Path parameters should also follow camelCase naming
- Certain values can be exempted via the ignoredValues configuration that can be supplied as
ignoredValues
argument to the rule - Paths with
x-xgen-IPA-exception
for this rule are excluded from validation - Double slashes (//) are not allowed in paths
Paths should alternate between resource names and path params.
Rule checks for the following conditions:
- Paths must follow a pattern where resource names and path parameters strictly alternate
- Even-indexed path segments should be resource names (not path parameters)
- Odd-indexed path segments should be path parameters
- Paths with
x-xgen-IPA-exception
for this rule are excluded from validation
Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers.
Rule checks for the following conditions:
- All path segments that are not path parameters must match pattern
/^[a-z][a-zA-Z0-9]*$/
- Path parameters (inside curly braces) are excluded from validation
- Custom methods (segments containing colons) are excluded from validation
- Paths with
x-xgen-IPA-exception
for this rule are excluded from validation - Each non-parameter path segment must start with a lowercase letter followed by any combination of ASCII letters and numbers
Rules are based on http://go/ipa/IPA-104.
APIs must provide a Get method for resources.
Rule checks for the following conditions:
- Only applies to resource collection identifiers
- For singleton resources, verifies the resource has a GET method
- For regular resources, verifies there is a single resource path with a GET method
The purpose of the Get method is to return data from a single resource.
Rule checks for the following conditions:
- Applies only to 2xx responses of GET methods on single resources or singleton resources
- Verifies the response is not an array or paginated result
- Different error messages are provided for standard vs singleton resources
The Get method must return a 200 OK response.
Rule checks for the following conditions:
- Applies only to GET methods on single resources or singleton resources
- Verifies the 200 OK response code is present
- Fails if the method lacks a 200 OK response or defines a different 2xx status code
The Get method of a resource should return a "Response" suffixed object.
Rule checks for the following conditions:
- Applies only to 2xx responses of GET methods on single resources or singleton resources
- Verifies the schema references a predefined schema (not inline)
- Confirms the referenced schema name ends with "Response" suffix
The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields).
Rule checks for the following conditions:
- Applies only to 2xx responses of GET methods on single resources or singleton resources
- Searches through the schema to find any properties marked with writeOnly attribute
- Fails if any writeOnly properties are found in the response schema
The Get method request must not include a body.
Rule checks for the following conditions:
- Applies only to GET methods on single resources or singleton resources
- Verifies that the operation object does not contain a requestBody property
Rules are based on http://go/ipa/IPA-105.
The List method must return a 200 OK response.
Rule checks for the following conditions:
- Applies only to GET methods on resource collection paths
- Ignores singleton resources
- Verifies the 200 OK response code is present
- Fails if the method lacks a 200 OK response or defines a different 2xx status code
The List method request must not include a body.
Rule checks for the following conditions:
- Applies only to GET methods on resource collection paths
- Ignores singleton resources
- Verifies that the operation object does not contain a requestBody property
APIs must provide a List method for resources.
Rule checks for the following conditions:
- Applies only to resource collection paths
- Ignores singleton resources
- Verifies the resource path has a GET method
- Fails if the resource path does not have a GET method
The response body of the List method should consist of the same resource object returned by the Get method.
- Applies only to resource collection paths with JSON content types
- Ignores singleton resources
- Ignores responses without a schema or non-paginated responses
- A response is considered paginated if it has a schema with a 'results' array property
- Verifies that the schema of items in the 'results' array matches the schema used in the Get method response
- Fails if the Get method doesn't have a schema reference or if the schemas don't match
- Validation ignores resources without a Get method
- Paths with
x-xgen-IPA-exception
for this rule are excluded from validation
Rules are based on http://go/ipa/IPA-106.
The Create method request should be a Request suffixed object.
Rule checks for the following conditions:
- Applies only to POST methods on resource collection paths (non-singleton resources)
- Applies only to JSON content types
- Verifies the schema references a predefined schema (not inline)
- Confirms the referenced schema name ends with "Request" suffix
Create operations should not use query parameters.
Rule checks for the following conditions:
- Applies only to POST methods on resource collection paths (non-singleton resources)
- Verifies the operation does not contain query parameters
- Ignores specified parameters like 'pretty' and 'envelope' via configuration
Request body content of the Create method and response content of the Get method should refer to the same resource.
Validation checks the POST method for resource collection paths.
- Validation ignores resources without a Get method.
readOnly:true
properties of Get method response will be ignored.writeOnly:true
properties of Create method request will be ignored.- Property comparison is based on
type
andname
matching. oneOf
anddiscriminator
definitions must match exactly.
Create method Request object must not include fields with readOnly:true.
Rule checks for the following conditions:
- Applies only to POST methods on resource collection paths (non-singleton resources)
- Applies only to JSON content types
- Searches through the request schema to find any properties marked with readOnly attribute
- Fails if any readOnly properties are found in the request schema
Create methods must return a 201 Created response code.
Rule checks for the following conditions:
- Applies only to POST methods on resource collection paths (non-singleton resources)
- Verifies the 201 Created response code is present
- Fails if the method lacks a 201 Created response or defines a different 2xx status code
The response body of the Create method should consist of the same resource object returned by the Get method.
Rule checks for the following conditions:
- Applies only to POST methods on resource collection paths
- Applies only to JSON response content types
- Verifies that both Create and Get methods have schema references
- Confirms that the Create method 201 response schema reference matches the Get method response schema reference
- Ignores resources without a Get method
- Paths with
x-xgen-IPA-exception
for this rule are excluded from validation
Rules are based on http://go/ipa/IPA-107.
Update operations must not accept query parameters.
Validation checks the PATCH/PUT methods for single resource paths and singleton resources.
- Query parameters
envelope
andpretty
are exempt from this rule - Operation objects with
x-xgen-IPA-exception
for this rule are excluded from validation
The Update method response status code should be 200 OK.
Validation checks the PATCH/PUT methods for single resource paths and singleton resources.
- Operation objects with
x-xgen-IPA-exception
for this rule are excluded from validation
The response body of the Update method should consist of the same resource object returned by the Get method.
- Applies only to single resource paths and singleton resources with JSON content types
- Ignores singleton resources and responses without a schema
- Validation ignores resources without a Get method
- Fails if the Get method doesn't have a schema reference or if the schemas don't match
- Paths with
x-xgen-IPA-exception
for this rule are excluded from validation
Update method Request object must not include fields with readOnly:true.
Rule checks for the following conditions:
- Applies only to Update methods on single resource paths or singleton resources
- Applies only to JSON content types
- Searches through the request schema to find any properties marked with readOnly attribute
- Fails if any readOnly properties are found in the request schema
The request body must contain the resource being updated, i.e. the resource or parts of the resource returned by the Get method.
Validation checks the PATCH/PUT methods for single resource paths and singleton resources.
- Validation ignores resources without a Get method.
readOnly:true
properties of Get method response will be ignored.writeOnly:true
properties of Update method request will be ignored.- Property comparison is based on
type
andname
matching. oneOf
anddiscriminator
definitions must match exactly.
The Update method request schema should reference an
UpdateRequest
suffixed object.
Rule checks for the following conditions:
- Applies to PUT/PATCH methods on single resource paths and singleton resources
- Applies only to JSON content types
- Validation only applies to schema references to a predefined schema (not inline)
- Confirms the referenced schema name ends with "Request" suffix
Rules are based on http://go/ipa/IPA-108.
Delete method response should not have schema reference to object.
Rule checks for the following conditions:
- Applies to 204 responses in DELETE methods for single resource endpoints (with path parameters)
- Verifies that the response does not contain a schema property
- Fails if any content type in the response has a defined schema as reference
- Skips validation for collection endpoints (without path parameters)
DELETE method must return 204 No Content.
Rule checks for the following conditions:
- Applies to all DELETE methods for single resource endpoints (with path parameters)
- Verifies the 204 No Content response code is present
- Fails if the method lacks a 204 No Content response or defines a different 2xx status code
- Ensures no other 2xx response codes are defined
- Fails if the 204 status code is missing or if other 2xx responses exist
- Skips validation for collection endpoints (without path parameters)
DELETE method must not have request body.
Rule checks for the following conditions:
- Applies to all DELETE methods for single resource endpoints (with path parameters)
- Verifies that the operation object does not contain a requestBody property
- Fails if any requestBody is defined for the DELETE method
- Skips validation for collection endpoints (without path parameters)
Rules are based on http://go/ipa/IPA-109.
The HTTP method for custom methods must be GET or POST.
Rule checks for the following conditions:
- Applies only to paths containing custom method identifiers (with colon format)
- Verifies the HTTP methods used are either GET or POST
- Fails if any other HTTP methods are used (PUT, DELETE, PATCH, etc.)
- Fails if multiple valid methods are defined for the same custom method endpoint
The custom method must use camelCase format.
Rule checks for the following conditions:
- Applies only to paths containing custom method identifiers (with colon format)
- Extracts the method name portion following the colon
- Verifies the method name is not empty or blank
- Validates that the method name uses proper camelCase formatting
- Fails if the method name contains invalid casing (such as snake_case, PascalCase, etc.)
Custom methods must be defined using a colon followed by the method name.
Rule checks for the following conditions:
- Identifies paths containing a colon (potential custom methods)
- Validates that the path follows proper custom method format
- Does not validate after the colon (xgen-IPA-109-custom-method-must-use-camel-case rule validates the method name)
- Fails if a slash appears before a colon
- Fails if multiple colons appear in the path
- Fails if other than an alphabetical character or a closing curly brace appears before a colon
Rules are based on http://go/ipa/IPA-110.
APIs that return collections of resources must use a schema with the "Paginated" prefix.
Rule checks for the following conditions:
- Only applies to List methods (GET operations that return collections of resources)
- Checks if List method has a response schema defined
- Checks that the 200 response schema references a schema with a "Paginated" prefix
The response for collections must define an array of results containing the paginated resource.
Rule checks for the following conditions:
- Only applies to List methods (GET operations that return collections of resources)
- Verifies the 200 response schema has the required results fields
The request should support an integer itemsPerPage query parameter allowing users to specify the maximum number of results to return per page.
itemsPerPage must not be required
itemsPerPage default value should be 100.
Rule checks for the following conditions:
- Only applies to List methods (GET on resource collection paths)
- Verifies the operation includes itemsPerPage query parameter
- Verifies the itemsPerPage query parameter is not required
- Verifies the itemsPerPage query parameter has a default value of 100
The request should support an integer pageNum query parameter allowing users to specify the maximum number of results to return per page.
pageNum must not be required
pageNum default value should be 1.
Rule checks for the following conditions:
- Only applies to List methods (GET on resource collection paths)
- Verifies the operation includes pageNum query parameter
- Verifies the pageNum query parameter is not required
- Verifies the pageNum query parameter has a default value of 1
If the request supports an includeCount query parameter, it must not be required.
Rule checks for the following conditions:
- Only applies to List methods (GET on resource collection paths)
- Checks if includeCount query parameter exists
- If it exists, verifies the includeCount parameter is not required
The response for collections should define a links array field, providing links to next and previous pages.
Rule checks for the following conditions:
- Only applies to List methods (GET operations that return collections of resources)
- Verifies the response schema includes a links field of type array
Rules are based on http://go/ipa/IPA-112.
Schema field names should avoid using "project", "projects", or "projectId".
Rule checks for the following conditions:
- Searches through all schemas in the API definition
- Identifies property names that match "project" (case-insensitive)
- Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId")
- Reports any instances where these field names are used
- Suggests using "group", "groups", or "groupId" as alternatives
Schema field names should be in camelCase format.
Rule checks for the following conditions:
- Searches through all schemas in the API definition
- Identifies property names that are not in camelCase format
- Reports any instances where these field names are not in camelCase format
Boolean field names should avoid the "is" prefix.
Rule checks for the following conditions:
- Applies only to properties with type 'boolean'
- Identifies property names that start with "is" followed by an uppercase letter
- Suggests using the direct adjective form instead (e.g., "disabled" instead of "isDisabled")
Rules are based on http://go/ipa/IPA-113.
Singleton resources must not have a user-provided or system-generated ID.
Rule checks for the following conditions:
- Applies only to singleton resources that are identified as resource collection identifiers
- Checks that the resource has a GET method defined
- Examines all 2xx response schemas from the GET method
- Verifies that no schema contains 'id' or '_id' properties in their object definitions
- Fails if any response schema contains these identifier properties
Singleton resources must not define the Delete standard method.
Rule checks for the following conditions:
- Applies only to singleton resources
- Checks that the resource does not have a DELETE method defined
Singleton resources should define the Update method. Validation for the presence of Get method is covered by IPA-104 (see xgen-IPA-104-resource-has-GET).
Rule checks for the following conditions:
- Applies only to singleton resources
- Checks that the resource has the PUT and/or PATCH methods defined
Rules are based on http://go/ipa/IPA-114.
APIs must return ApiError when errors occur
This rule checks that all 4xx and 5xx error responses reference the ApiError schema.
ApiError schema should have badRequestDetail field with proper structure.
Rule checks that:
- ApiError schema has badRequestDetail field
- badRequestDetail must include an array of fields
- Each field must include description and field properties
- This rule does not allow exceptions
Authenticated endpoints must define 401 and 403 responses.
This rule checks that all authenticated endpoints (those without explicit 'security: []' and not containing '/unauth' in the path) include 401 and 403 responses.
Paths with parameters must define 404 responses.
This rule checks that all endpoints with path parameters (identified by '{param}' in the path) include a 404 response to handle the case when the requested resource is not found.
Rules are based on http://go/ipa/IPA-117.
API producers must provide descriptions for Properties, Operations and Parameters.
Rule checks for description property in the following components:
- Info object
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties The rule also fails if the description is an empty string.
Descriptions must start with Uppercase.
Rule checks the format of the description property in the following components:
- Info object
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties
Descriptions must end with a full stop(.).
Rule checks the format of the description property in the following components:
- Info object
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties
The rule ignores descriptions that end with
|
, i.e. inline markdown tables
Descriptions must not use raw HTML.
Rule checks the format of the descriptions for components:
- Info object
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties The rule validates that the description content does not include opening and/or closing HTML tags.
Descriptions should not include inline tables as this may not work well with all tools, in particular generated client code.
Rule checks the format of the descriptions for components:
- Info object
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties The rule validates that the description content does not include inline markdown tables.
Descriptions should not include inline links.
Rule checks the format of the descriptions for components:
- Tags
- Operation objects
- Inline schema properties for operation object requests and responses
- Parameter objects (in operations and components)
- Schema properties
The rule validates that the description content does not include inline markdown links. The rule ignores HTML
<a>
links - this is covered byxgen-IPA-117-description-must-not-use-html
.
For APIs that respond with plain text, for example CSV, API producers must provide an example. Some tools are not able to generate examples for such responses
- The rule only applies to 2xx responses
- The rule ignores JSON and YAML responses (passed as
allowedTypes
) - The rule ignores responses with
format: 'binary'
(i.e. file types) - The rule checks for the presence of the example property as a sibling to the
schema
property, or inside theschema
object
Components of type "object" must be well-defined, i.e. have of one of the properties:
schema
examples
example
oneOf
,anyOf
orallOf
properties
additionalProperties
The rule applies to the following components:
- Inline operation responses/request bodies (JSON only)
- Inline operation response/request body properties (JSON only)
- Inline operation response/request body array items (JSON only)
- Schemas defined in
components/schemas
- Schema properties defined in
components/schemas
items
properties defined incomponents/schemas
The rule is applied to the unresolved OAS, and ignores components with$ref
properties. Specific paths can be ignored using theignoredPaths
option.
API producers must provide a well-defined schema or example(s) for parameters.
The rule checks for the presence of the schema
, examples
or example
property in:
- Operation parameters
- Parameters defined in
components/parameters
Rules are based on http://go/ipa/IPA-118.
Schemas must not use
additionalProperties: false
This rule checks that schemas don't restrict additional properties by setting additionalProperties: false
.
Schemas without explicit additionalProperties
settings (which default to true) or with additionalProperties
set to true
are compliant.
This rule checks all nested schemas, but only parent schemas can be marked for exception.
Rules are based on http://go/ipa/IPA-119.
When using a provider field or parameter, API producers should not define a default value.
This rule checks fields and parameters named "cloudProvider" and ensures they do not have a default value.
It also checks enum fields that might contain cloud provider values.
All cloudProviderEnumValues should be listed in the enum array.
Rules are based on http://go/ipa/IPA-121.
Fields with format="date-time" should mention ISO 8601 and UTC in their description.
It collects adoption metrics at schema property level and parameter level
Rules are based on http://go/ipa/IPA-123.
Enum values must be UPPER_SNAKE_CASE.
Rule checks for the following conditions:
- Applies to all enum value arrays defined in the OpenAPI schema
- Resolves the schema object that contains the enum values
- Validates each enum value individually against the UPPER_SNAKE_CASE pattern
- Skips validation if the schema has an exception defined for this rule
Allowable enum values should not exceed 20 entries.
Rule checks for the following conditions:
- Applies to inline enum values
- Validates that each enum array has 20 or fewer values
- Reusable enum schemas will be ignored
- Skips validation if the schema has an exception defined for this rule
- This validation threshold can be adjusted by changing the functionOptions.maxEnumValues parameter
Rules are based on http://go/ipa/IPA-124.
Array fields must have a maxItems property defined to enforce an upper bound on the number of items (recommended max: 100). If the array field has the chance of being too large, the API should use a sub-resource instead.
Rule checks for the following conditions:
- All schema objects with type 'array' must have a maxItems property
- The maxItems value must be set below the threshold of 100
- maxItems: Required integer parameter specifying the maximum allowed array size (default: 100)
- ignore: Required array parameter listing property names to be exempted from validation
Rules are based on http://go/ipa/IPA-125.
Each oneOf property must include a discriminator property to define the exact type.
Rule checks for the following conditions:
- Applies only to schemas with
oneOf
containing references - Ensures a
discriminator
property is present with a validpropertyName
- Validates that
discriminator.mapping
contains exactly the same number of entries asoneOf
references - Validates that each
discriminator.mapping
value matches a reference in theoneOf
array - Ignores
oneOf
definitions with inline schemas
- The
discriminator.mapping
must have the same number of entries as there are references in theoneOf
array - Each value in the
discriminator.mapping
must match one of the$ref
values in theoneOf
array - Each
$ref
in theoneOf
array must have a corresponding entry in thediscriminator.mapping
- Example:
This is valid because there are exactly 2 mappings for 2 oneOf references, and all values match.
oneOf: - $ref: '#/components/schemas/Dog' - $ref: '#/components/schemas/Cat' discriminator: propertyName: type mapping: dog: '#/components/schemas/Dog' cat: '#/components/schemas/Cat'
API producers should not use oneOf with different base types like integer, string, boolean, or number or references at the same time.
Rule checks for the following conditions:
- Applies to schemas with
oneOf
arrays - Ensures no mixing of base types with references
- Ensures no multiple different base types in the same oneOf
- Base types considered are: integer, string, boolean, number
- Using the same base type multiple times is allowed (e.g., multiple string enums)
Using oneOf with multiple primitive types can lead to ambiguity and validation problems. Clients may not be able to properly determine which type to use in which context. Instead, use more specific object types with clear discriminators.
Rules are based on http://go/ipa/IPA-126.
Tag names in the OpenAPI specification should use Title Case.
Rule checks for the following conditions:
- All tag names defined in the OpenAPI tags object should use Title Case
- Title Case means each word starts with an uppercase letter, and the rest are lowercase
- Certain abbreviations (like "API", "AWS", etc.) in the ignoreList are allowed to maintain their casing
- Grammatical words (like "and", "or", "the", etc.) are allowed to be all lowercase
This rule includes two configuration options:
ignoreList
: Words that are allowed to maintain their specific casing (e.g., "API", "AWS", "DNS")grammaticalWords
: Common words that can remain lowercase in titles (e.g., "and", "or", "the")