Bifrost · API Governance Rules

Bifrost API Rules

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

28 Rules error 7 warn 21
View Rules File View on GitHub

Rule Categories

bifrost error no schema

Rules

error
bifrost-info-title-prefix
API title must start with "Bifrost"
$.info.title
error
bifrost-info-version-present
API info must have a version field
$.info
warn
bifrost-info-contact-present
API info must include contact details
$.info
error
bifrost-operation-summary-prefix
Operation summaries must start with "Bifrost"
$.paths[*][*].summary
warn
bifrost-operation-id-camel-case
Operation IDs must be camelCase
$.paths[*][*].operationId
warn
bifrost-operation-tags-present
Every operation must have at least one tag
$.paths[*][*]
warn
bifrost-operation-description-present
Every operation must have a description
$.paths[*][*]
warn
bifrost-path-kebab-case
Paths must use kebab-case segments
$.paths
error
bifrost-request-body-required
POST operations must have a request body
$.paths[*].post
error
bifrost-response-200-present
Every operation must define a 200 or 201 response
$.paths[*][*].responses
warn
bifrost-response-error-schema
Error responses must reference ErrorResponse schema
$.paths[*][*].responses[?(@property >= '400')].content.application/json.schema
warn
bifrost-schema-title-present
All schemas must have a title
$.components.schemas[*]
warn
bifrost-schema-description-present
All schemas must have a description
$.components.schemas[*]
warn
bifrost-schema-properties-described
Schema properties must have descriptions
$.components.schemas[*].properties[*]
error
bifrost-security-scheme-present
API must define at least one security scheme
$.components
warn
bifrost-operation-security-present
Operations should reference a security scheme
$.paths[*][post,put,patch,delete]
warn
bifrost-tags-defined
All tags used in operations must be defined at top level
$.tags
warn
bifrost-tag-description-present
Top-level tags must have a description
$.tags[*]
error
bifrost-servers-present
API must define servers
$
warn
bifrost-chat-model-format
Chat completion model must use provider/model format
$.components.schemas.ChatCompletionRequest.properties.model
warn
bifrost-operation-examples-present
Responses with content should include examples
$.paths[*][*].responses[*].content[*]
warn
bifrost-microcks-operation-present
Every operation must include x-microcks-operation extension
$.paths[*][*]
warn
bifrost-license-present
API info must include license
$.info
warn
bifrost-license-apache
License must be Apache 2.0
$.info.license.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 (ErrorResponse) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# bifrost — 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:
#   - operationid-casing: camel @ 100% (n=3)
#   - schema-names-casing: pascal @ 100% (n=8)
#   - schema-properties-casing: snake @ 100% (n=28)
#   - security: neither global nor consistently per-op — schemes-defined only
#   - error-schema-defined: ErrorResponse
#   - merge: kept 24 existing, added 4 measured, upgraded 0
#   - added: schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  bifrost-info-title-prefix:
    description: API title must start with "Bifrost"
    message: 'Info title must start with "Bifrost": {{value}}'
    severity: error
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Bifrost
  bifrost-info-version-present:
    description: API info must have a version field
    message: Info object must include a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  bifrost-info-contact-present:
    description: API info must include contact details
    message: Info object must include contact
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  bifrost-operation-summary-prefix:
    description: Operation summaries must start with "Bifrost"
    message: 'Operation summary must start with "Bifrost": {{value}}'
    severity: error
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: ^Bifrost
  bifrost-operation-id-camel-case:
    description: Operation IDs must be camelCase
    message: 'OperationId must be camelCase: {{value}}'
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  bifrost-operation-tags-present:
    description: Every operation must have at least one tag
    message: Operations must include tags
    severity: warn
    given: $.paths[*][*]
    then:
      field: tags
      function: truthy
  bifrost-operation-description-present:
    description: Every operation must have a description
    message: Operations must include description
    severity: warn
    given: $.paths[*][*]
    then:
      field: description
      function: truthy
  bifrost-path-kebab-case:
    description: Paths must use kebab-case segments
    message: 'Path segments must be kebab-case: {{value}}'
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9-{}]*)+$
  bifrost-request-body-required:
    description: POST operations must have a request body
    message: POST operations must include requestBody
    severity: error
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy
  bifrost-response-200-present:
    description: Every operation must define a 200 or 201 response
    message: Operations must include a 200 response
    severity: error
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
  bifrost-response-error-schema:
    description: Error responses must reference ErrorResponse schema
    message: Error responses should reference the ErrorResponse schema
    severity: warn
    given: $.paths[*][*].responses[?(@property >= '400')].content.application/json.schema
    then:
      function: truthy
  bifrost-schema-title-present:
    description: All schemas must have a title
    message: Schemas must include title
    severity: warn
    given: $.components.schemas[*]
    then:
      field: title
      function: truthy
  bifrost-schema-description-present:
    description: All schemas must have a description
    message: Schemas must include description
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  bifrost-schema-properties-described:
    description: Schema properties must have descriptions
    message: Schema properties must include description
    severity: warn
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  bifrost-security-scheme-present:
    description: API must define at least one security scheme
    message: Components must include securitySchemes
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  bifrost-operation-security-present:
    description: Operations should reference a security scheme
    message: Operations should include security definition
    severity: warn
    given: $.paths[*][post,put,patch,delete]
    then:
      field: security
      function: truthy
  bifrost-tags-defined:
    description: All tags used in operations must be defined at top level
    message: Tags must be defined in the global tags section
    severity: warn
    given: $.tags
    then:
      function: truthy
  bifrost-tag-description-present:
    description: Top-level tags must have a description
    message: Tags must include a description
    severity: warn
    given: $.tags[*]
    then:
      field: description
      function: truthy
  bifrost-servers-present:
    description: API must define servers
    message: Servers array must be present and non-empty
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  bifrost-chat-model-format:
    description: Chat completion model must use provider/model format
    message: Chat model field should use provider/model-name format
    severity: warn
    given: $.components.schemas.ChatCompletionRequest.properties.model
    then:
      field: description
      function: truthy
  bifrost-operation-examples-present:
    description: Responses with content should include examples
    message: Response content should include examples
    severity: warn
    given: $.paths[*][*].responses[*].content[*]
    then:
      field: examples
      function: truthy
  bifrost-microcks-operation-present:
    description: Every operation must include x-microcks-operation extension
    message: Operations must include x-microcks-operation
    severity: warn
    given: $.paths[*][*]
    then:
      field: x-microcks-operation
      function: truthy
  bifrost-license-present:
    description: API info must include license
    message: Info must include license
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  bifrost-license-apache:
    description: License must be Apache 2.0
    message: 'License must be Apache 2.0: {{value}}'
    severity: warn
    given: $.info.license.name
    then:
      function: pattern
      functionOptions:
        match: Apache
  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 (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy