2020 Police Brutality · API Governance Rules

2020 Police Brutality API Rules

Spectral linting rules defining API design standards and conventions for 2020 Police Brutality.

23 Rules error 11 warn 10 info 2
View Rules File View on GitHub

Rule Categories

get info no openapi operation operationid response schema servers tags

Rules

error
info-title-required
API info title must be present.
$.info
warn
info-description-required
API info description must be present and meaningful.
$.info
error
info-version-required
API version must be defined.
$.info
warn
info-license-required
Open data APIs should include a license.
$.info
error
openapi-version-3
Must use OpenAPI 3.0.x.
$
error
servers-must-be-defined
Servers array must be defined.
$
warn
servers-description-required
Each server should have a description.
$.servers[*]
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation should have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
error
response-success-required
Every operation must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-description-required
Component schemas should have descriptions.
$.components.schemas[*]
warn
schema-type-required
Schemas should define a type.
$.components.schemas[*]
info
schema-properties-described
Schema properties should have descriptions.
$.components.schemas[*].properties[*]
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
tags-defined
Global tags array should be defined for documentation.
$
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the githubusercontent.com domain.
$.servers[*].url
warn
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties

Spectral Ruleset

Raw ↑
# 2020-police-brutality — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 1/1 servers on githubusercontent.com
#   - operationid-casing: camel @ 100% (n=3)
#   - schema-properties-casing: snake @ 100% (n=15)
#   - merge: kept 19 existing, added 4 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, operationid-casing, schema-properties-casing
extends:
  - spectral:oas
rules:
  info-title-required:
    description: API info title must be present.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: API info description must be present and meaningful.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: API version must be defined.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-license-required:
    description: Open data APIs should include a license.
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  openapi-version-3:
    description: Must use OpenAPI 3.0.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.0\.
  servers-must-be-defined:
    description: Servers array must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-description-required:
    description: Each server should have a description.
    severity: warn
    given: $.servers[*]
    then:
      field: description
      function: truthy
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Every operation should have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  response-success-required:
    description: Every operation must define at least one 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  response-description-required:
    description: Every response must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  schema-description-required:
    description: Component schemas should have descriptions.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-type-required:
    description: Schemas should define a type.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  schema-properties-described:
    description: Schema properties should have descriptions.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy
  tags-defined:
    description: Global tags array should be defined for documentation.
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the githubusercontent.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: githubusercontent\.com
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: casing
      functionOptions:
        type: camel
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake