REST Guidelines Ruleset

October 17, 2022 ยท View on GitHub

The REST Guidelines Ruleset of an OpenAPI Specification (OAS) document consists of 3 domains:

  • REST Conventions (naming resources and representations)
  • REST Style (HTTP methods, headers, query parameters, and status codes)
  • REST Additional (errors, verbs, and authorization)

REST Conventions Rules

Learn more about the REST Conventions used to make the following rules.

name_iddescriptionseveritymitigation
resource-pas-camel-case-infoResource names use lowerCamelCase.warningPlease update resource names in PasCamelCase format for the items identified. Note that this is a variant of Reference
resource-pas-camel-case-errorResource names use lowerCamelCase.errorPlease update resource names in PasCamelCase format for the items identified. Note that this is a variant of Reference
resource-lower-camel-case-infoResource names use lowerCamelCase.warningPlease update resource names for the items identified. Reference
resource-lower-camel-case-errorResource names use lowerCamelCase.errorPlease update resource names for the items identified. Reference
oas2-application-json-charset-utf8-requiredJSON representations should be declared using 'application/json' or 'application/json; charset=UTF-8' media types.errorPlease update content type for the items identified. Reference
oas3-application-json-charset-utf8-requiredJSON representations should be declared using 'application/json' or 'application/json; charset=UTF-8' media types.errorPlease update content type for the items identified. Reference
oas2-collections-returned-as-arraysCollections are returned as arrays encapsulated with a named field such as 'items'.errorPlease update response for the items identified. Reference
oas3-collections-returned-as-arraysCollections are returned as arrays encapsulated with a named field such as 'items'.errorPlease update response for the items identified. Reference
oas2-field-names-pas-camel-caseRepresentation field names use lowerCamelCase.errorPlease update field names in PasCamelCase format for the items identified. Note that this is a variant of Reference
oas3-field-names-pas-camel-caseRepresentation field names use lowerCamelCase.errorPlease update field names in PasCamelCase format for the items identified. Note that this is a variant of Reference
oas2-field-names-camel-caseRepresentation field names use lowerCamelCase.errorPlease update field names for the items identified. [Reference](rest-conventions.md#representation-fields
oas3-field-names-camel-caseRepresentation field names use lowerCamelCase.errorPlease update field names for the items identified. Reference
oas2-no-boolean-string-enumsRepresentation fields use format-native true/false values for booleans.errorPlease update boolean fields for the items identified. Reference
oas3-no-boolean-string-enumsRepresentation fields use format-native true/false values for booleans.errorPlease update boolean fields for the items identified. Reference

REST Style Rules

Learn more about the REST Style used to make the following rules.

name_iddescriptionseveritymitigation
post-headerPOST operations that create resources should include a Location header.errorPlease add location header for the items identified. Reference
post-header-locationPOST operations that create resources should include a Location header.errorPlease add location header for the items identified. Reference
oas2-post-201-createdPOST operations which create objects return 201 Created, with a full or reference-only representation.errorPlease update responses for the items identified. Reference
put-200-204-successPUT operations return either '200 OK' with full representation or '204 No Content'.errorPlease update response for the items identified. Reference
delete-204-successDELETE operations return '204 No Content' on success.errorPlease update the spec. Reference
patch-200-204-successPATCH operations return either '200 OK' with full representation or '204 No Content'.errorPlease update response for the items identified. Reference
head-operations-match-headers-with-getHEAD operations must return response headers identical to the corresponding GET.errorPlease update response headers for the items identified. Reference
oas2-head-operations-no-bodyHEAD operations with a corresponding GET operation must return no body content.errorPlease update response body for the items identified. Reference
oas3-head-operations-no-bodyHEAD operations with a corresponding GET operation must return no body content.errorPlease update response body for the items identified. Reference
oas2-request-header-date-correct-typeHTTP headers follow the syntax specified in the corresponding RFCs.errorPlease update headers for the items identified. Reference
oas2-request-header-date-correct-regexHTTP headers follow the syntax specified in the corresponding RFCs.errorPlease update headers for the items identified. Reference
oas2-request-header-accept-language-enumHTTP headers follow the syntax specified in the corresponding RFCs.errorPlease update headers for the items identified. Reference
date-response-header-requirementAll responses include a 'Date' header in the GMT timezone and RFC 5322 format.errorPlease add a date header for the items identified. Reference
date-response-header-format-pattern-requirementAll responses include a 'Date' header in the GMT timezone and RFC 5322 format.warningPlease add a date header for the items identified. Reference
date-response-header-regex-checkAll responses include a 'Date' header in the GMT timezone and RFC 5322 format.warningPlease add a date header for the items identified. Reference
tracking-id-header-requirementAll responses must include a 'TrackingID' header.errorPlease add a TrackingID response header for the items identified. Reference
oas2-tracking-id-header-string-requirement'TrackingID' header should be a string in order to accommodate a UUID.warningPlease update TrackingID response header for the items identified. Reference
oas3-tracking-id-header-string-requirement'TrackingID' header should be a string in order to accommodate a UUID.warningPlease update TrackingID response header for the items identified. Reference
etag-header-match-requiredIn cases where ETag is supported, such resources should also support If-Match and If-None-Match request headers.errorPlease add If-Match and If-None-Match headers for the items identified. Reference
no-etag-cache-control-header-requiredWhere caching is not appropriate, operations must include a Cache-Control header (e.g. max-age=0, no-cache)lowPlease add a Cache-Control header for the items identified. Reference
oas2-order-parameter-asc-descOrdering collections is designed with an 'order' query parameter specifying 'asc' or 'desc'.errorPlease update order values for the items identified. Reference
sort-recommend-orderConsider using 'order' with 'sort' in this operation.lowPlease add order query for the items identified. Reference
oas3-order-parameter-asc-descOrdering collections is designed with an 'order' query parameter specifying 'asc' or 'desc'.errorPlease update order values for the items identified. Reference
respond-with-recommended-get-codesMy API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx rangeserrorPlease update response codes for the items identified. Reference
respond-with-recommended-post-codesMy API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx rangeserrorPlease update response codes for the items identified. Reference
respond-with-recommended-patch-codesMy API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx rangeserrorPlease update response codes for the items identified. Reference
respond-with-recommended-put-codesMy API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx rangeserrorPlease update response codes for the items identified. Reference
respond-with-recommended-delete-codesMy API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx rangeserrorPlease update response codes for the items identified. Reference
status-codes-in-2xx-4xx-5xxAPI responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges.errorPlease update responses for the items identified. Reference
status-codes-in-2xx-3xx-4xx-5xxAPI responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges.errorPlease update responses for the items identified. Reference

REST Additional Rules

Learn more about the REST Additional used to make the following rules.

name_iddescriptionseveritymitigation
oas2-error-messageError representations include a useful human-readable message.errorPlease update error message for the items identified.
oas3-error-messageError representations include a useful human-readable message.errorPlease update error message for the items identified.
error-response-identifierError representations include an identifier to help with troubleshooting.warningPlease add an error identifier for the items identified.
no-crud-verbsStandard CRUD lifecycle operations map to HTTP verbs; Functional resources are used when non-standard CRUD are needed.errorPlease update resource names for the items identified.
oas3-jwt-formatMy API access tokens are passed via the HTTP 'Authorization' header, with a 'Bearer' prefix.errorPlease update authorization for the items identified.