agrio · API Governance Rules

agrio API Rules

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

21 Rules error 9 warn 11 info 1
View Rules File View on GitHub

Rule Categories

get info no operation paths response schema security servers

Rules

error
info-title-required
OpenAPI info must have a title.
$.info
warn
info-title-prefix
API title should start with "Agrio".
$.info.title
warn
info-description-required
OpenAPI info must have a description.
$.info
error
info-version-required
OpenAPI info must have a version.
$.info
error
servers-defined
At least one server must be defined.
$
error
servers-https-required
Server URLs must use HTTPS.
$.servers[*].url
warn
paths-kebab-case
Path segments should use kebab-case.
$.paths[*]~
info
paths-versioned
Paths should include a version prefix (e.g., /v1/).
$.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 "Agrio".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
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
warn
response-401-defined
Protected operations should define a 401 response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-description-required
Top-level component schemas should have a description.
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined.
$.components
warn
security-bearer-used
APIs should use Bearer token authentication.
$.components.securitySchemes[*]
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

Spectral Ruleset

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

  info-title-prefix:
    description: API title should start with "Agrio".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: "^Agrio"

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

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

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

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

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

  paths-versioned:
    description: Paths should include a version prefix (e.g., /v1/).
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: "^/v[0-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 "Agrio".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^Agrio"

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

  operation-id-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: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  # RESPONSES
  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: truthy

  response-401-defined:
    description: Protected operations should define a 401 response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: "401"
      function: truthy

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

  # SCHEMAS
  schema-description-required:
    description: Top-level component schemas should have a description.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy

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

  security-bearer-used:
    description: APIs should use Bearer token authentication.
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: scheme
      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

  # QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy