Rithum · API Governance Rules

Rithum API Rules

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

11 Rules error 2 warn 7 info 2
View Rules File View on GitHub

Rule Categories

dsco

Rules

warn
dsco-operation-has-tag
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
error
dsco-operation-has-summary
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
dsco-operation-has-description
All operations should have a description
$.paths[*][get,post,put,patch,delete]
error
dsco-operation-has-operation-id
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
dsco-operation-id-camel-case
OperationIds should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
warn
dsco-responses-have-error-schema
Error responses should reference a schema
$.paths[*][*].responses[4*,5*].content[*]
warn
dsco-post-has-request-body
POST operations should have a requestBody
$.paths[*].post
warn
dsco-bearer-auth-defined
Security scheme should be BearerAuth
$.components.securitySchemes[*]
info
dsco-batch-request-has-array
Batch request schemas should contain array properties
$.components.schemas[*BatchRequest]
warn
dsco-path-uses-kebab-case
API paths should use kebab-case
$.paths[*]~
info
dsco-schema-has-description
Schema properties should have descriptions
$.components.schemas[*].properties[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Rithum / Dsco API Conventions

  dsco-operation-has-tag:
    description: All operations must have at least one tag
    message: Operation {{path}} is missing a tag
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  dsco-operation-has-summary:
    description: All operations must have a summary
    message: Operation {{path}} is missing a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  dsco-operation-has-description:
    description: All operations should have a description
    message: Operation {{path}} is missing a description
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  dsco-operation-has-operation-id:
    description: All operations must have an operationId
    message: Operation {{path}} is missing an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  dsco-operation-id-camel-case:
    description: OperationIds should use camelCase
    message: OperationId {{value}} should use camelCase
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  dsco-responses-have-error-schema:
    description: Error responses should reference a schema
    message: Response {{path}} should define a schema
    severity: warn
    given: "$.paths[*][*].responses[4*,5*].content[*]"
    then:
      field: schema
      function: truthy

  dsco-post-has-request-body:
    description: POST operations should have a requestBody
    message: POST operation {{path}} is missing a requestBody
    severity: warn
    given: "$.paths[*].post"
    then:
      field: requestBody
      function: truthy

  dsco-bearer-auth-defined:
    description: Security scheme should be BearerAuth
    message: Security scheme {{path}} should use bearer authentication
    severity: warn
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              type: string
              enum:
                - http
          required:
            - type

  dsco-batch-request-has-array:
    description: Batch request schemas should contain array properties
    message: Batch request {{path}} should include array fields
    severity: info
    given: "$.components.schemas[*BatchRequest]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  dsco-path-uses-kebab-case:
    description: API paths should use kebab-case
    message: Path {{path}} should use kebab-case segments
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9][a-z0-9-]*({[a-zA-Z]+})?)*$"

  dsco-schema-has-description:
    description: Schema properties should have descriptions
    message: Schema {{path}} is missing a description
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy