Thermal Power · API Governance Rules

Thermal Power API Rules

Spectral linting rules defining API design standards and conventions for Thermal Power.

8 Rules error 3 warn 4 info 1
View Rules File View on GitHub

Rule Categories

thermal

Rules

warn
thermal-power-operation-summary-title-case
All operation summaries must use Title Case.
$.paths[*][*].summary
warn
thermal-power-operation-ids-camel-case
All operationIds must use camelCase.
$.paths[*][*].operationId
error
thermal-power-api-key-required
All operations must require api_key query parameter.
$.paths[*][get,post].parameters[?(@.name == 'api_key')]
warn
thermal-power-pagination-params
All list operations should support offset and length pagination.
$.paths[*][get]
error
thermal-power-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
thermal-power-description-required
All operations must have a description.
$.paths[*][get,post,put,patch,delete]
error
thermal-power-200-response-defined
All GET operations must define a 200 response.
$.paths[*][get].responses
info
thermal-power-path-data-suffix
EIA API data paths should end with /data.
$.paths[*]~

Spectral Ruleset

Raw ↑
rules:
  thermal-power-operation-summary-title-case:
    description: All operation summaries must use Title Case.
    message: "Operation summary '{{value}}' must use Title Case."
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  thermal-power-operation-ids-camel-case:
    description: All operationIds must use camelCase.
    message: "OperationId '{{value}}' must be camelCase."
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  thermal-power-api-key-required:
    description: All operations must require api_key query parameter.
    message: "Operation at '{{path}}' must define api_key as a required query parameter."
    severity: error
    given: "$.paths[*][get,post].parameters[?(@.name == 'api_key')]"
    then:
      field: required
      function: truthy

  thermal-power-pagination-params:
    description: All list operations should support offset and length pagination.
    message: "List operation at '{{path}}' should support offset/length pagination."
    severity: warn
    given: "$.paths[*][get]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  thermal-power-tags-required:
    description: All operations must have at least one tag.
    message: "Operation at '{{path}}' must have at least one tag."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  thermal-power-description-required:
    description: All operations must have a description.
    message: "Operation at '{{path}}' is missing a description."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  thermal-power-200-response-defined:
    description: All GET operations must define a 200 response.
    message: "GET operation at '{{path}}' must define a 200 response."
    severity: error
    given: "$.paths[*][get].responses"
    then:
      field: "200"
      function: defined

  thermal-power-path-data-suffix:
    description: EIA API data paths should end with /data.
    message: "Path '{{path}}' should follow EIA pattern ending with /data."
    severity: info
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: ".*\\/data$"