Zally · API Governance Rules

Zally API Rules

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

18 Rules error 5 warn 13
View Rules File View on GitHub

Rule Categories

info openapi operation parameter paths response schema security servers

Rules

error
info-title-required
API title is required
$.info
warn
info-description-required
API description is required
$.info
error
info-version-required
API version is required
$.info
warn
info-contact-required
API contact is required
$.info
warn
openapi-version-3
OpenAPI version should be 3.x
$
error
servers-required
Servers must be defined
$
warn
servers-https
Server URLs should use HTTPS
$.servers[*]
warn
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths
warn
paths-kebab-case
Path segments should be kebab-case
$.paths
warn
operation-summary-required
Operation summary is required
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Operation description is required
$.paths[*][get,post,put,patch,delete]
error
operation-operationId-required
operationId is required
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Operation tags are required
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-prefix-zally
Operation summary should start with "Zally"
$.paths[*][get,post,put,patch,delete].summary
warn
parameter-description-required
Parameters need a description
$.paths[*][*].parameters[*]
error
response-2xx-required
Operations must define a 2xx success response
$.paths[*][get,post,put,patch,delete].responses
warn
schema-description-required
Top-level schemas need a description
$.components.schemas[*]
warn
security-schemes-defined
Security schemes should be defined
$.components

Spectral Ruleset

Raw ↑
rules:
  info-title-required:
    description: API title is required
    message: '{{property}} is required'
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: API description is required
    message: '{{property}} is required'
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: API version is required
    message: '{{property}} is required'
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: API contact is required
    message: '{{property}} is required'
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  openapi-version-3:
    description: OpenAPI version should be 3.x
    message: Use OpenAPI 3.x
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-required:
    description: Servers must be defined
    message: Define servers
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs should use HTTPS
    message: Use HTTPS
    severity: warn
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: ^https://
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    message: Remove trailing slash
    severity: warn
    given: $.paths
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: .+/$
  paths-kebab-case:
    description: Path segments should be kebab-case
    message: Use kebab-case
    severity: warn
    given: $.paths
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9-]+|/\{[a-zA-Z][a-zA-Z0-9_]*\})+/?$
  operation-summary-required:
    description: Operation summary is required
    message: Add a summary
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Operation description is required
    message: Add a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-operationId-required:
    description: operationId is required
    message: Add operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-tags-required:
    description: Operation tags are required
    message: Add tags
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  operation-summary-prefix-zally:
    description: Operation summary should start with "Zally"
    message: Summary should start with "Zally"
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^Zally
  parameter-description-required:
    description: Parameters need a description
    message: Add a description
    severity: warn
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  response-2xx-required:
    description: Operations must define a 2xx success response
    message: Add a 2xx response
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: pattern
      functionOptions:
        match: ^[23]
      field: '@key'
  schema-description-required:
    description: Top-level schemas need a description
    message: Add a description
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    description: Security schemes should be defined
    message: Define securitySchemes
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy