Appmixer · API Governance Rules

Appmixer API Rules

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

19 Rules error 7 warn 11 info 1
View Rules File View on GitHub

Rule Categories

http info no operation parameter paths response schema security servers

Rules

warn
info-title-appmixer-prefix
API title should start with "Appmixer"
$.info
error
info-version-required
API version must be specified
$.info
warn
info-description-required
API description must be present
$.info
error
servers-required
At least one server must be defined
$
warn
servers-https
Server URLs must use HTTPS
$.servers[*]
warn
security-bearer-auth
Appmixer APIs use Bearer JWT authentication
$.components.securitySchemes
warn
paths-kebab-case
Path segments must use kebab-case
$.paths
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-id-camel-case
OperationId must use camelCase
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation must have a description
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
Every parameter must have a description
$.paths[*][get,post,put,patch,delete].parameters[*]
error
operation-success-response-required
Every operation must have a 2xx response
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-title-required
Component schemas should have a title
$.components.schemas[*]
info
schema-snake-case-properties
Schema property names should use camelCase
$.components.schemas[*].properties
error
http-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-appmixer-prefix:
    description: API title should start with "Appmixer"
    severity: warn
    given: $.info
    then:
      field: title
      function: pattern
      functionOptions:
        match: "^Appmixer"

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

  info-description-required:
    description: API description must be present
    severity: warn
    given: $.info
    then:
      field: description
      function: minLength
      functionOptions:
        min: 20

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

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

  # SECURITY
  security-bearer-auth:
    description: Appmixer APIs use Bearer JWT authentication
    severity: warn
    given: $.components.securitySchemes
    then:
      field: bearerAuth
      function: truthy

  # PATHS — NAMING
  paths-kebab-case:
    description: Path segments must use kebab-case
    severity: warn
    given: $.paths
    then:
      field: "@key"
      function: pattern
      functionOptions:
        match: "^(/[a-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-id-required:
    description: Every operation must have an operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy

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

  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-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

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

  # RESPONSES
  operation-success-response-required:
    description: Every operation must have a 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-description-required:
    description: Every response must have a description
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy

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

  schema-snake-case-properties:
    description: Schema property names should use camelCase
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: "@key"
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9_]*$"

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

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