HashiCorp Vault · API Governance Rules

HashiCorp Vault API Rules

Spectral linting rules defining API design standards and conventions for HashiCorp Vault.

33 Rules error 11 warn 17 info 5
View Rules File View on GitHub

Rule Categories

delete error get info no openapi operation parameter path paths response schema security servers tags vault

Rules

error
info-title-required
API title must be present.
$.info
warn
info-title-starts-with-hashicorp-vault
API title should start with "HashiCorp Vault".
$.info.title
warn
info-description-required
API info description must be present.
$.info
error
info-version-required
API version must be specified.
$.info
error
openapi-version-3x
API specification must use OpenAPI 3.x.
$
error
servers-required
Servers array must be defined.
$
error
servers-https-required
Server URLs must use HTTPS.
$.servers[*].url
info
paths-v1-prefix
All Vault API paths begin at the server level v1 — paths should be relative.
$.paths
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths
error
operation-operationId-required
All operations must have an operationId.
$.paths[*][get,post,put,patch,delete,options,head]
warn
operation-operationId-camelCase
operationId should use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-summary-required
All operations must have a summary.
$.paths[*][get,post,put,patch,delete,options,head]
warn
operation-summary-starts-with-hashicorp-vault
Operation summaries should start with "HashiCorp Vault".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
All operations should have a description.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
tags-global-defined
Global tags array should be defined.
$
warn
parameter-description-required
All parameters should have a description.
$..parameters[*]
error
response-success-required
Operations must define at least one success (2xx or 204) response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-403-required
Vault operations should define 403 Permission Denied response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have a description.
$.paths[*][*].responses[*]
warn
schema-description-required
Schema definitions should have descriptions.
$.components.schemas[*]
info
schema-properties-have-descriptions
Schema properties should have descriptions.
$.components.schemas[*].properties[*]
error
security-schemes-defined
Security schemes must be defined in components.
$.components
info
vault-token-header-not-bearer
Vault uses X-Vault-Token header, not Authorization Bearer.
$.components.securitySchemes[?(@.type == 'apiKey')]
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
info
delete-returns-204
DELETE operations should return 204 No Content.
$.paths[*].delete.responses
warn
no-empty-description
Descriptions must not be empty strings.
$..description
info
operation-has-microcks-extension
Operations should have x-microcks-operation for mock compatibility.
$.paths[*][get,post,put,patch,delete]
warn
servers-expected-domain
Server URLs should be on the example.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (VaultError) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# vault — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 2/2 servers on example.com
#   - path-params-casing: snake @ 100% (n=16)
#   - operationid-casing: camel @ 100% (n=25)
#   - schema-names-casing: pascal @ 100% (n=25)
#   - schema-properties-casing: snake @ 100% (n=50)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: VaultError
#   - operation-documents-403: 96% adherence
#   - merge: kept 28 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: API title must be present.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-starts-with-hashicorp-vault:
    description: API title should start with "HashiCorp Vault".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^HashiCorp Vault
  info-description-required:
    description: API info description must be present.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: API version must be specified.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3x:
    description: API specification must use OpenAPI 3.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-required:
    description: Servers array must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https-required:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-v1-prefix:
    description: All Vault API paths begin at the server level v1 — paths should be relative.
    severity: info
    given: $.paths
    then:
      function: pattern
      functionOptions:
        notMatch: ^/v1
  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  operation-operationId-required:
    description: All operations must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: operationId
      function: truthy
  operation-operationId-camelCase:
    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-summary-required:
    description: All operations must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: summary
      function: truthy
  operation-summary-starts-with-hashicorp-vault:
    description: Operation summaries should start with "HashiCorp Vault".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^HashiCorp Vault
  operation-description-required:
    description: All operations should have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: All operations must have at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  tags-global-defined:
    description: Global tags array should be defined.
    severity: warn
    given: $
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: All parameters should have a description.
    severity: warn
    given: $..parameters[*]
    then:
      field: description
      function: truthy
  response-success-required:
    description: Operations must define at least one success (2xx or 204) response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '204'
  response-403-required:
    description: Vault operations should define 403 Permission Denied response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '403'
      function: truthy
  response-description-required:
    description: All responses must have a description.
    severity: error
    given: $.paths[*][*].responses[*]
    then:
      field: description
      function: truthy
  schema-description-required:
    description: Schema definitions should have descriptions.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-properties-have-descriptions:
    description: Schema properties should have descriptions.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  vault-token-header-not-bearer:
    description: Vault uses X-Vault-Token header, not Authorization Bearer.
    severity: info
    given: $.components.securitySchemes[?(@.type == 'apiKey')]
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^X-Vault-Token$
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-returns-204:
    description: DELETE operations should return 204 No Content.
    severity: info
    given: $.paths[*].delete.responses
    then:
      field: '204'
      function: truthy
  no-empty-description:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  operation-has-microcks-extension:
    description: Operations should have x-microcks-operation for mock compatibility.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the example.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: example\.com
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (VaultError) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: VaultError
      function: truthy