Siemens · API Governance Rules

Siemens API Rules

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

8 Rules error 3 warn 5
View Rules File View on GitHub

Rule Categories

siemens

Rules

error
siemens-bearer-auth-required
Siemens Building X APIs must use Bearer token authentication
$.components.securitySchemes[*]
warn
siemens-odata-pagination
List endpoints should support OData skip/top pagination
$.paths[*].get.parameters[?(@.in == 'query')]
error
siemens-operation-summary-required
All operations must have a summary
$.paths[*][*]
warn
siemens-equipment-type-enum
Equipment type fields should use enumeration
$.components.schemas[*].properties.type
warn
siemens-status-enum
Status fields must define enumerated values
$.components.schemas[*].properties.status
warn
siemens-list-response-value-array
List responses should use OData value array wrapper
$.components.schemas[?(@.properties.value)]
warn
siemens-timestamp-format
Timestamp fields must use ISO 8601 date-time format
$.components.schemas[*].properties[?(@.description =~ /timestamp|time|date/i)]
error
siemens-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,delete,patch]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Siemens Building X APIs use Bearer token auth
  siemens-bearer-auth-required:
    description: Siemens Building X APIs must use Bearer token authentication
    message: API security must include Bearer token scheme
    severity: error
    given: "$.components.securitySchemes[*]"
    then:
      field: scheme
      function: enumeration
      functionOptions:
        values:
          - bearer

  # Building data follows OData paging conventions (skip/top)
  siemens-odata-pagination:
    description: List endpoints should support OData skip/top pagination
    message: List operation should define skip and top query parameters
    severity: warn
    given: "$.paths[*].get.parameters[?(@.in == 'query')]"
    then:
      field: name
      function: pattern
      functionOptions:
        match: "^(skip|top|filter|select|orderby|from|to|status|type|severity|resolution)$"

  # All operations must have summary
  siemens-operation-summary-required:
    description: All operations must have a summary
    message: Operation is missing a summary
    severity: error
    given: "$.paths[*][*]"
    then:
      field: summary
      function: truthy

  # Building equipment types should use consistent naming
  siemens-equipment-type-enum:
    description: Equipment type fields should use enumeration
    message: Equipment type should use a defined enumeration
    severity: warn
    given: "$.components.schemas[*].properties.type"
    then:
      field: enum
      function: truthy

  # Status fields should enumerate valid values
  siemens-status-enum:
    description: Status fields must define enumerated values
    message: Status field should define an enum
    severity: warn
    given: "$.components.schemas[*].properties.status"
    then:
      field: enum
      function: truthy

  # List responses should use OData value wrapper
  siemens-list-response-value-array:
    description: List responses should use OData value array wrapper
    message: List response should wrap results in a 'value' array property
    severity: warn
    given: "$.components.schemas[?(@.properties.value)]"
    then:
      field: properties.value.type
      function: enumeration
      functionOptions:
        values:
          - array

  # Timestamps must use ISO 8601 format
  siemens-timestamp-format:
    description: Timestamp fields must use ISO 8601 date-time format
    message: "Timestamp field '{{property}}' should use format: date-time"
    severity: warn
    given: "$.components.schemas[*].properties[?(@.description =~ /timestamp|time|date/i)]"
    then:
      field: format
      function: enumeration
      functionOptions:
        values:
          - date-time
          - date

  # Operations must have operationId
  siemens-operation-id-required:
    description: All operations must have an operationId
    message: Operation is missing an operationId
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: operationId
      function: truthy