Biogen · API Governance Rules

Biogen API Rules

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

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

Rule Categories

biogen error no schema servers

Rules

error
biogen-info-title-prefix
API title must start with "Biogen"
$.info.title
error
biogen-info-version-present
API info must have a version field
$.info
warn
biogen-info-contact-present
API info must include contact details
$.info
error
biogen-operation-summary-prefix
Operation summaries must start with "Biogen"
$.paths[*][*].summary
warn
biogen-operation-id-camel-case
Operation IDs must be camelCase
$.paths[*][*].operationId
warn
biogen-operation-tags-present
Every operation must have at least one tag
$.paths[*][*]
warn
biogen-operation-description-present
Every operation must have a description
$.paths[*][*]
error
biogen-response-success-present
Every operation must define a success response
$.paths[*][*].responses
warn
biogen-response-401-present
Operations should define a 401 response
$.paths[*][*].responses
warn
biogen-schema-title-present
All schemas must have a title
$.components.schemas[*]
warn
biogen-schema-description-present
All schemas must have a description
$.components.schemas[*]
warn
biogen-schema-properties-described
Schema properties must have descriptions
$.components.schemas[*].properties[*]
error
biogen-security-scheme-present
API must define at least one security scheme
$.components
warn
biogen-api-key-auth
Biogen API uses X-API-Key header authentication
$.components.securitySchemes[*]
warn
biogen-operation-security-present
Operations must declare security
$.paths[*][get,post,put,patch,delete]
warn
biogen-tags-defined
All tags used in operations must be defined at top level
$.tags
error
biogen-servers-present
API must define servers
$
error
biogen-server-https
Server URL must use HTTPS
$.servers[*].url
warn
biogen-operation-examples-present
Responses with content should include examples
$.paths[*][*].responses[*].content[*]
warn
biogen-microcks-operation-present
Every operation must include x-microcks-operation extension
$.paths[*][*]
warn
biogen-unused-components
All components should be referenced
$.components.schemas
warn
biogen-license-present
API info must include license
$.info
warn
biogen-path-kebab-case
Path segments should be lowercase
$.paths
warn
servers-expected-domain
Server URLs should be on the biogen.com domain.
$.servers[*].url
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 ↑
# biogen — 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: 1/1 servers on biogen.com
#   - operationid-casing: camel @ 100% (n=3)
#   - schema-names-casing: pascal @ 100% (n=7)
#   - schema-properties-casing: snake @ 100% (n=18)
#   - operation-security-required: 3/3 ops declare per-op security
#   - error-schema-defined: ErrorResponse
#   - merge: kept 23 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  biogen-info-title-prefix:
    description: API title must start with "Biogen"
    message: 'Info title must start with "Biogen": {{value}}'
    severity: error
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Biogen
  biogen-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
  biogen-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
  biogen-operation-summary-prefix:
    description: Operation summaries must start with "Biogen"
    message: 'Operation summary must start with "Biogen": {{value}}'
    severity: error
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: ^Biogen
  biogen-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]*$
  biogen-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
  biogen-operation-description-present:
    description: Every operation must have a description
    message: Operations must include description
    severity: warn
    given: $.paths[*][*]
    then:
      field: description
      function: truthy
  biogen-response-success-present:
    description: Every operation must define a success response
    message: Operations must include a 200 or 201 response
    severity: error
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
  biogen-response-401-present:
    description: Operations should define a 401 response
    message: Operations should include 401 unauthorized response
    severity: warn
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - '401'
          - required:
            - '403'
  biogen-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
  biogen-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
  biogen-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
  biogen-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
  biogen-api-key-auth:
    description: Biogen API uses X-API-Key header authentication
    message: Security scheme should use X-API-Key header
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      function: truthy
  biogen-operation-security-present:
    description: Operations must declare security
    message: Operations must include security definition
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: truthy
  biogen-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
  biogen-servers-present:
    description: API must define servers
    message: Servers array must be present and non-empty
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  biogen-server-https:
    description: Server URL must use HTTPS
    message: 'Server URL must use HTTPS: {{value}}'
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  biogen-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
  biogen-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
  biogen-unused-components:
    description: All components should be referenced
    message: Unused components should be removed
    severity: warn
    given: $.components.schemas
    then:
      function: truthy
  biogen-license-present:
    description: API info must include license
    message: Info must include license
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  biogen-path-kebab-case:
    description: Path segments should be lowercase
    message: 'Path segments should use lowercase: {{value}}'
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9-/{}]*)+$
  servers-expected-domain:
    description: Server URLs should be on the biogen.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: biogen\.com
  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