BeyondTrust · API Governance Rules

BeyondTrust API Rules

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

23 Rules error 10 warn 11 info 2
View Rules File View on GitHub

Rule Categories

credential http info no openapi operation parameter response schema security servers

Rules

warn
info-title-prefix
API title should start with "BeyondTrust"
$.info.title
error
info-description-required
API info must have a description
$.info
error
info-version-required
API must specify a version
$.info
warn
openapi-version-3
Should use OpenAPI 3.0.x
$.openapi
error
servers-defined
At least one server must be defined
$
error
operation-summary-required
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-prefix
Operation summaries should start with "BeyondTrust"
$.paths[*][get,post,put,patch,delete].summary
error
operation-id-required
All operations must have operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-id-camel-case
operationId should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
warn
operation-tags-required
Operations must have tags
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Operations should have descriptions
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
Parameters must have descriptions
$.paths[*][get,post,put,patch,delete].parameters[*]
error
response-success-required
Operations must define a success response
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Response descriptions are required
$.paths[*][get,post,put,patch,delete].responses[*]
info
response-401-for-auth
Auth endpoints should return 401 on failure
$.paths[*][post].responses
warn
schema-description-required
Component schemas should have descriptions
$.components.schemas[*]
info
schema-pascal-case-names
Schema names should use PascalCase
$.components.schemas
error
security-schemes-defined
Security schemes must be defined
$.components
warn
security-global-defined
Global security should be defined
$
error
http-get-no-body
GET operations should not have request bodies
$.paths[*].get
warn
http-delete-no-body
DELETE operations should not have request bodies
$.paths[*].delete
error
credential-endpoint-secured
Credential retrieval endpoints must require authentication
$.paths['/requests/{requestId}/credentials'].get
warn
no-empty-descriptions
Descriptions should not be empty
$..description

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-prefix:
    description: API title should start with "BeyondTrust"
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: "^BeyondTrust"

  info-description-required:
    description: API info must have a description
    severity: error
    given: $.info
    then:
      field: description
      function: truthy

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

  # OPENAPI VERSION
  openapi-version-3:
    description: Should use OpenAPI 3.0.x
    severity: warn
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: "^3\\.0\\."

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

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

  operation-summary-prefix:
    description: Operation summaries should start with "BeyondTrust"
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^BeyondTrust"

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

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

  operation-tags-required:
    description: Operations must have tags
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  operation-description-required:
    description: Operations should have descriptions
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy

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

  # RESPONSES
  response-success-required:
    description: Operations must define a success response
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  response-description-required:
    description: Response descriptions are required
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy

  response-401-for-auth:
    description: Auth endpoints should return 401 on failure
    severity: info
    given: $.paths[*][post].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object

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

  schema-pascal-case-names:
    description: Schema names should use PascalCase
    message: "Schema name '{{path}}' should use PascalCase"
    severity: info
    given: $.components.schemas
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy

  security-global-defined:
    description: Global security should be defined
    severity: warn
    given: $
    then:
      field: security
      function: truthy

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

  http-delete-no-body:
    description: DELETE operations should not have request bodies
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy

  # PAM-SPECIFIC
  credential-endpoint-secured:
    description: Credential retrieval endpoints must require authentication
    severity: error
    given: $.paths['/requests/{requestId}/credentials'].get
    then:
      field: security
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 0

  no-empty-descriptions:
    description: Descriptions should not be empty
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: ".+"