Sigma-Aldrich · API Governance Rules

Sigma-Aldrich API Rules

Spectral linting rules defining API design standards and conventions for Sigma-Aldrich.

8 Rules error 4 warn 4
View Rules File View on GitHub

Rule Categories

sigma

Rules

error
sigma-aldrich-api-key-auth
Sigma-Aldrich API must use API key authentication via x-api-key header
$.components.securitySchemes[?(@.type == 'apiKey')]
warn
sigma-aldrich-search-requires-query
Product search endpoints must require a search query parameter
$.paths[?(@property =~ /search/)].get.parameters[?(@.in == 'query')]
warn
sigma-aldrich-cas-number-format
CAS number path parameters should validate the CAS format pattern
$.components.parameters[?(@.name == 'casNumber')]
error
sigma-aldrich-structure-search-required-fields
Structure search request must include structure and searchType fields
$.components.schemas.StructureSearchRequest
error
sigma-aldrich-operation-summary-required
All operations must have a summary
$.paths[*][*]
error
sigma-aldrich-operation-id-required
All operations must define an operationId
$.paths[*][get,post,put,delete,patch]
warn
sigma-aldrich-stock-level-enum
Stock level field should use enumerated values
$.components.schemas[*].properties.stockLevel
warn
sigma-aldrich-search-results-pagination
Search result schemas should include total, page, and pageSize
$.components.schemas.ProductSearchResults.properties

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Sigma-Aldrich uses API key authentication
  sigma-aldrich-api-key-auth:
    description: Sigma-Aldrich API must use API key authentication via x-api-key header
    message: API security must use apiKey type with x-api-key header
    severity: error
    given: "$.components.securitySchemes[?(@.type == 'apiKey')]"
    then:
      field: name
      function: enumeration
      functionOptions:
        values:
          - x-api-key

  # Product search must require a query parameter
  sigma-aldrich-search-requires-query:
    description: Product search endpoints must require a search query parameter
    message: Search endpoint should require a 'q' query parameter
    severity: warn
    given: "$.paths[?(@property =~ /search/)].get.parameters[?(@.in == 'query')]"
    then:
      field: name
      function: pattern
      functionOptions:
        match: "^(q|query|keyword|cas|smiles|inchi)$"

  # CAS number parameters should validate format
  sigma-aldrich-cas-number-format:
    description: CAS number path parameters should validate the CAS format pattern
    message: CAS number parameter should use format validation pattern
    severity: warn
    given: "$.components.parameters[?(@.name == 'casNumber')]"
    then:
      field: schema.pattern
      function: truthy

  # Chemical structure searches should require structure and searchType
  sigma-aldrich-structure-search-required-fields:
    description: Structure search request must include structure and searchType fields
    message: Structure search schema must require 'structure' and 'searchType' fields
    severity: error
    given: "$.components.schemas.StructureSearchRequest"
    then:
      field: required
      function: truthy

  # All operations must have a summary
  sigma-aldrich-operation-summary-required:
    description: All operations must have a summary
    message: Operation is missing a summary
    severity: error
    given: "$.paths[*][*]"
    then:
      field: summary
      function: truthy

  # Operations must have operationId
  sigma-aldrich-operation-id-required:
    description: All operations must define an operationId
    message: Operation is missing an operationId
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: operationId
      function: truthy

  # Stock level should use enumeration
  sigma-aldrich-stock-level-enum:
    description: Stock level field should use enumerated values
    message: stockLevel should define an enum
    severity: warn
    given: "$.components.schemas[*].properties.stockLevel"
    then:
      field: enum
      function: truthy

  # Search results should include pagination metadata
  sigma-aldrich-search-results-pagination:
    description: Search result schemas should include total, page, and pageSize
    message: Search results should define total, page, and pageSize properties
    severity: warn
    given: "$.components.schemas.ProductSearchResults.properties"
    then:
      field: total
      function: truthy