Abortion Policy API · API Governance Rules

Abortion Policy API API Rules

Spectral linting rules defining API design standards and conventions for Abortion Policy API.

32 Rules error 16 warn 15 info 1
View Rules File View on GitHub

Rule Categories

delete examples get info no openapi operation parameter paths response schema security server servers tag tags

Rules

error
info-title-required
API info must have a title.
$.info
warn
info-title-format
API title should follow the "Abortion Policy API ..." naming pattern.
$.info.title
error
info-description-required
API info must have a description.
$.info
error
info-version-required
API info must have a version.
$.info
error
openapi-version
API must use OpenAPI 3.x.
$
error
servers-required
At least one server must be defined.
$
error
server-https-required
All server URLs must use HTTPS.
$.servers[*].url
warn
server-description-required
Each server should have a description.
$.servers[*]
warn
paths-kebab-case
Path segments should use kebab-case or underscore_case.
$.paths
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-prefix
Operation summaries should start with "Abortion Policy API".
$.paths[*][get,post,put,patch,delete].summary
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]
warn
operation-operationid-camelcase
OperationIds must use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
tags-array-defined
Global tags array should be defined.
$
warn
tag-description-required
Each global tag should have a description.
$.tags[*]
warn
tag-name-title-case
Tag names should use Title Case.
$.tags[*].name
error
parameter-description-required
All parameters must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
error
parameter-schema-required
All parameters must have a schema.
$.paths[*][get,post,put,patch,delete].parameters[*]
error
response-success-required
Every operation must have at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-required
Every authenticated operation should have a 401 response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-property-description
Top-level schemas should have descriptions.
$.components.schemas[*]
warn
schema-type-defined
All schemas should have a type defined.
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined in components.
$.components
warn
security-scheme-description
Security schemes should have descriptions.
$.components.securitySchemes[*]
warn
operation-security-defined
Every operation should have security defined.
$.paths[*][get,post,put,patch,delete]
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
delete-no-request-body
DELETE operations must not have a request body.
$.paths[*].delete
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Operations should have examples for better developer experience.
$.paths[*][get,post,put,patch,delete].responses[*].content[*]

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-required:
    description: API info must have a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy

  info-title-format:
    description: API title should follow the "Abortion Policy API ..." naming pattern.
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: "^Abortion Policy API"

  info-description-required:
    description: API info must have a description.
    severity: error
    given: $.info
    then:
      field: description
      function: truthy

  info-version-required:
    description: API info must have a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version:
    description: API must use OpenAPI 3.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-required:
    description: At least one server must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  server-https-required:
    description: All server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  server-description-required:
    description: Each server should have a description.
    severity: warn
    given: $.servers[*]
    then:
      field: description
      function: truthy

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments should use kebab-case or underscore_case.
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9_-]+(/[a-z0-9_-]+|/\\{[a-zA-Z0-9_]+\\})*)+$"

  # OPERATIONS
  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-summary-prefix:
    description: Operation summaries should start with "Abortion Policy API".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^Abortion Policy API"

  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-operationid-camelcase:
    description: OperationIds must use camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  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

  # TAGS
  tags-array-defined:
    description: Global tags array should be defined.
    severity: warn
    given: $
    then:
      field: tags
      function: truthy

  tag-description-required:
    description: Each global tag should have a description.
    severity: warn
    given: $.tags[*]
    then:
      field: description
      function: truthy

  tag-name-title-case:
    description: Tag names should use Title Case.
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z]*(\\s[A-Z][a-zA-Z]*)*$"

  # PARAMETERS
  parameter-description-required:
    description: All parameters must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy

  parameter-schema-required:
    description: All parameters must have a schema.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: schema
      function: truthy

  # RESPONSES
  response-success-required:
    description: Every operation must have at least one 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['204']

  response-401-required:
    description: Every authenticated operation should have a 401 response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          required: ['401']

  response-description-required:
    description: All responses must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy

  # SCHEMAS — PROPERTY NAMING
  schema-property-description:
    description: Top-level schemas should have descriptions.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy

  schema-type-defined:
    description: All schemas should have a type defined.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy

  security-scheme-description:
    description: Security schemes should have descriptions.
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy

  operation-security-defined:
    description: Every operation should have security defined.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy

  delete-no-request-body:
    description: DELETE operations must not have a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: error
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: ".+"

  examples-encouraged:
    description: Operations should have examples for better developer experience.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses[*].content[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['example']
            - required: ['examples']