Greenhouse · API Governance Rules

Greenhouse API Rules

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

13 Rules error 5 warn 7 info 1
View Rules File View on GitHub

Rule Categories

info openapi operation parameter paths response security servers

Rules

error
info-title-required
Info object must have a title.
$.info
warn
info-description-required
Info object must have a description.
$.info
error
info-version-required
Info object must have a version.
$.info
error
openapi-version-3
OpenAPI version must be 3.x.
$.openapi
error
servers-defined
Servers must be defined.
$
warn
servers-https
Server URLs must use HTTPS.
$.servers[*].url
warn
paths-kebab-case
Path segments should be kebab-case or templated.
$.paths.*~
warn
paths-no-trailing-slash
Paths should not end with a trailing slash.
$.paths.*~
warn
operation-summary-required
Operations must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Operations should have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
parameter-snake-case
Parameter names should be snake_case.
$.paths[*][*].parameters[?(@.in == 'query')].name
error
response-success-required
Operations must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
security-defined
Security schemes must be defined.
$.components.securitySchemes

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  info-title-required:
    description: Info object must have a title.
    given: $.info
    severity: error
    then:
      field: title
      function: truthy
  info-description-required:
    description: Info object must have a description.
    given: $.info
    severity: warn
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info object must have a version.
    given: $.info
    severity: error
    then:
      field: version
      function: truthy

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

  # SERVERS
  servers-defined:
    description: Servers must be defined.
    given: $
    severity: error
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS.
    given: $.servers[*].url
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  # PATHS
  paths-kebab-case:
    description: Path segments should be kebab-case or templated.
    given: $.paths.*~
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^(/([a-z0-9_\\-]+|\\{[a-zA-Z0-9_]+\\}))*/?$"
  paths-no-trailing-slash:
    description: Paths should not end with a trailing slash.
    given: $.paths.*~
    severity: warn
    then:
      function: pattern
      functionOptions:
        notMatch: ".+/$"

  # OPERATIONS
  operation-summary-required:
    description: Operations must have a summary.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: summary
      function: truthy
  operation-tags-required:
    description: Operations should have at least one tag.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: tags
      function: truthy

  # PARAMETERS
  parameter-snake-case:
    description: Parameter names should be snake_case.
    given: $.paths[*][*].parameters[?(@.in == 'query')].name
    severity: info
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-z0-9_]*$"

  # RESPONSES
  response-success-required:
    description: Operations must define at least one 2xx response.
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            "^2[0-9][0-9]$": {}
          minProperties: 1

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