Eaton · API Governance Rules

Eaton API Rules

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

6 Rules error 3 warn 3
View Rules File View on GitHub

Rule Categories

eaton

Rules

warn
eaton-info-contact
Info object MUST identify the Eaton AbleEdge Developer Portal as contact.
$.info
error
eaton-bearer-and-subscription-key
All Eaton EM API operations MUST require both OAuth2 Bearer and Em-Api-Subscription-Key.
$
error
eaton-subscription-key-header-name
The subscription-key apiKey scheme MUST use header name `Em-Api-Subscription-Key`.
$.components.securitySchemes[?(@.type=='apiKey')]
warn
eaton-title-case-summary
Operation summaries MUST be in Title Case.
$.paths.*[get,post,put,patch,delete].summary
error
eaton-hardware-type-enum
Device.hardwareType MUST be one of `emcb` or `ev-emcb`.
$.components.schemas.Device.properties.hardwareType
warn
eaton-ev-only-tag
EV-charger operations MUST be tagged `EV Only`.
$.paths[?(@property =~ /\/ev\//)][get,post,put,patch,delete]

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, all]]
documentationUrl: https://api.em.eaton.com/docs
rules:
  eaton-info-contact:
    description: Info object MUST identify the Eaton AbleEdge Developer Portal as contact.
    severity: warn
    given: $.info
    then:
      - field: contact.url
        function: pattern
        functionOptions:
          match: "portal.em.eaton.com|api.em.eaton.com|developer.eaton.com"

  eaton-bearer-and-subscription-key:
    description: All Eaton EM API operations MUST require both OAuth2 Bearer and Em-Api-Subscription-Key.
    severity: error
    given: $
    then:
      - field: components.securitySchemes.OAuth2
        function: truthy
      - field: components.securitySchemes.SubscriptionKey
        function: truthy

  eaton-subscription-key-header-name:
    description: The subscription-key apiKey scheme MUST use header name `Em-Api-Subscription-Key`.
    severity: error
    given: $.components.securitySchemes[?(@.type=='apiKey')]
    then:
      - field: name
        function: pattern
        functionOptions:
          match: "^Em-Api-Subscription-Key$"

  eaton-title-case-summary:
    description: Operation summaries MUST be in Title Case.
    severity: warn
    given: $.paths.*[get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)(\\s+[A-Z][a-zA-Z0-9]*)*$"

  eaton-hardware-type-enum:
    description: Device.hardwareType MUST be one of `emcb` or `ev-emcb`.
    severity: error
    given: $.components.schemas.Device.properties.hardwareType
    then:
      field: enum
      function: schema
      functionOptions:
        schema:
          type: array
          items: { type: string, enum: [emcb, ev-emcb] }

  eaton-ev-only-tag:
    description: EV-charger operations MUST be tagged `EV Only`.
    severity: warn
    given: $.paths[?(@property =~ /\/ev\//)][get,post,put,patch,delete]
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          contains: { const: "EV Only" }