mailboxlayer · API Governance Rules

mailboxlayer API Rules

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

11 Rules error 6 warn 4 info 1
View Rules File View on GitHub

Rule Categories

mailboxlayer

Rules

error
mailboxlayer-operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,delete,patch]
warn
mailboxlayer-operation-summary-title-case
Operation summaries should use Title Case (each major word capitalized).
$.paths[*][get,post,put,delete,patch].summary
error
mailboxlayer-operation-id-required
Every operation must define operationId.
$.paths[*][get,post,put,delete,patch]
error
mailboxlayer-operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,delete,patch]
error
mailboxlayer-access-key-required
Every operation must accept the `access_key` query parameter for authentication.
$.paths[*][get,post,put,delete,patch]
warn
mailboxlayer-server-host
Servers should use the canonical apilayer.net host.
$.servers[*].url
error
mailboxlayer-success-response-defined
Every operation must define a 200 response.
$.paths[*][get,post,put,delete,patch].responses
warn
mailboxlayer-response-content-json
Responses should be returned as application/json.
$.paths[*][get,post,put,delete,patch].responses[*].content
warn
mailboxlayer-info-contact-email
API info must include a support contact email.
$.info.contact
info
mailboxlayer-info-terms-of-service
API info should reference terms of service.
$.info
error
mailboxlayer-security-scheme-apikey
Security schemes must include an API key in the query string named `access_key`.
$.components.securitySchemes[*]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas
rules:
  # Enforce mailboxlayer's documentation conventions

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

  mailboxlayer-operation-summary-title-case:
    description: Operation summaries should use Title Case (each major word capitalized).
    given: $.paths[*][get,post,put,delete,patch].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-z0-9]*)(\\s+(A|An|And|As|At|But|By|For|In|Of|On|Or|The|To|With|[A-Z][A-Za-z0-9]*))*$"

  mailboxlayer-operation-id-required:
    description: Every operation must define operationId.
    given: $.paths[*][get,post,put,delete,patch]
    severity: error
    then:
      field: operationId
      function: truthy

  mailboxlayer-operation-tags-required:
    description: Every operation must have at least one tag.
    given: $.paths[*][get,post,put,delete,patch]
    severity: error
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  mailboxlayer-access-key-required:
    description: Every operation must accept the `access_key` query parameter for authentication.
    given: $.paths[*][get,post,put,delete,patch]
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            parameters:
              type: array
              contains:
                type: object
                properties:
                  name:
                    const: access_key
                  in:
                    const: query
                required: [name, in]
          required: [parameters]

  mailboxlayer-server-host:
    description: Servers should use the canonical apilayer.net host.
    given: $.servers[*].url
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^https?://apilayer\\.net/api"

  mailboxlayer-success-response-defined:
    description: Every operation must define a 200 response.
    given: $.paths[*][get,post,put,delete,patch].responses
    severity: error
    then:
      field: "200"
      function: truthy

  mailboxlayer-response-content-json:
    description: Responses should be returned as application/json.
    given: $.paths[*][get,post,put,delete,patch].responses[*].content
    severity: warn
    then:
      field: application/json
      function: truthy

  mailboxlayer-info-contact-email:
    description: API info must include a support contact email.
    given: $.info.contact
    severity: warn
    then:
      field: email
      function: truthy

  mailboxlayer-info-terms-of-service:
    description: API info should reference terms of service.
    given: $.info
    severity: info
    then:
      field: termsOfService
      function: truthy

  mailboxlayer-security-scheme-apikey:
    description: Security schemes must include an API key in the query string named `access_key`.
    given: $.components.securitySchemes[*]
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              const: apiKey
            in:
              const: query
            name:
              const: access_key