Bitbucket · API Governance Rules

Bitbucket API Rules

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

22 Rules error 8 warn 12 info 2
View Rules File View on GitHub

Rule Categories

delete get info no operation operationid pagination parameter paths query response schema security tag

Rules

error
info-title-required
Info object must have a title
$.info
error
info-description-required
Info object must have a description
$.info
error
info-version-required
Info object must have a version
$.info
warn
paths-kebab-case
Path segments should use kebab-case
$.paths
error
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths
error
operation-summary-required
Operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Operations must have a description
$.paths[*][get,post,put,patch,delete]
error
operation-operationid-required
Operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
info
operation-summary-prefix
Operation summaries should start with Bitbucket
$.paths[*][get,post,put,patch,delete].summary
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
warn
schema-type-required
Schemas should have a type defined
$.definitions[*]
warn
schema-property-snake-case
Schema properties should use snake_case
$.definitions[*].properties
warn
security-global-defined
Global security should be defined
$
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body
$.paths[*].delete
info
pagination-use-page
Paginated endpoints should use page-based pagination
$.paths[*].get.parameters[?(@.name=='page')]
warn
tag-title-case
Tag names should use Title Case
$.tags[*].name
warn
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# bitbucket — 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:
#   - path-params-casing: snake @ 99% (n=838)
#   - query-params-casing: snake @ 93% (n=100)
#   - operationid-casing: camel @ 100% (n=100)
#   - pagination params observed: ['page']
#   - merge: kept 19 existing, added 3 measured, upgraded 0
#   - added: query-params-casing, operationid-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info object must have a title
    given: $.info
    severity: error
    then:
      field: title
      function: truthy
  info-description-required:
    description: Info object must have a description
    given: $.info
    severity: error
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info object must have a version
    given: $.info
    severity: error
    then:
      field: version
      function: truthy
  paths-kebab-case:
    description: Path segments should use kebab-case
    given: $.paths
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9_-]+(/{[a-zA-Z_]+})?)*$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    given: $.paths
    severity: error
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: /$
  operation-summary-required:
    description: Operations must have a summary
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Operations must have a description
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: description
      function: truthy
  operation-operationid-required:
    description: Operations must have an operationId
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: operationId
      function: truthy
  operation-tags-required:
    description: Operations must have at least one tag
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: tags
      function: truthy
  operation-summary-prefix:
    description: Operation summaries should start with Bitbucket
    given: $.paths[*][get,post,put,patch,delete].summary
    severity: info
    then:
      function: pattern
      functionOptions:
        match: '^Bitbucket '
  parameter-description-required:
    description: Parameters must have descriptions
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    severity: warn
    then:
      field: description
      function: truthy
  response-success-required:
    description: Operations must define a success response
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '204'
  schema-type-required:
    description: Schemas should have a type defined
    given: $.definitions[*]
    severity: warn
    then:
      field: type
      function: truthy
  schema-property-snake-case:
    description: Schema properties should use snake_case
    given: $.definitions[*].properties
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  security-global-defined:
    description: Global security should be defined
    given: $
    severity: warn
    then:
      field: security
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body
    given: $.paths[*].get
    severity: error
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not have a request body
    given: $.paths[*].delete
    severity: warn
    then:
      field: requestBody
      function: falsy
  pagination-use-page:
    description: Paginated endpoints should use page-based pagination
    given: $.paths[*].get.parameters[?(@.name=='page')]
    severity: info
    then:
      field: name
      function: truthy
  tag-title-case:
    description: Tag names should use Title Case
    given: $.tags[*].name
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][A-Za-z0-9]*$
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy