Fixer · API Governance Rules

Fixer API Rules

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

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

Rule Categories

fixer

Rules

error
fixer-operation-id-required
Every operation must have a non-empty operationId.
$.paths[*][get,post,put,patch,delete]
warn
fixer-operation-id-camel-case
operationId values must be lowerCamelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
fixer-operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
fixer-operation-summary-title-case
Operation summaries must use Title Case.
$.paths[*][get,post,put,patch,delete].summary
warn
fixer-operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
warn
fixer-operation-tags-required
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
fixer-currency-code-example-format
Currency code examples (base/symbols/from/to) must be uppercase ISO 4217 codes.
$.paths[*].get.parameters[?(@.name=='base' || @.name=='from' || @.name=='to')].schema.example
warn
fixer-date-parameter-format
Date-valued parameters must declare schema.format = 'date'.
$.paths[*].get.parameters[?(@.name=='date' || @.name=='start_date' || @.name=='end_date')].schema
warn
fixer-response-success-envelope
Response schemas must include a `success` boolean property.
$.components.schemas[?(@property!='ErrorResponse' && @property!='FluctuationEntry')].properties
error
fixer-error-envelope
ErrorResponse schema must include success=false and a nested error object with code/type/info.
$.components.schemas.ErrorResponse.properties
error
fixer-apikey-security-scheme
ApiKeyAuth security scheme must be defined as a header named 'apikey'.
$.components.securitySchemes.ApiKeyAuth
warn
fixer-server-apilayer-required
At least one server must point at api.apilayer.com/fixer.
$.servers[*].url

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas
rules:
  # All operations MUST have an operationId in lowerCamelCase
  fixer-operation-id-required:
    description: Every operation must have a non-empty operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy

  fixer-operation-id-camel-case:
    description: operationId values must be lowerCamelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  # Every operation MUST have a summary in Title Case
  fixer-operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy

  fixer-operation-summary-title-case:
    description: Operation summaries must use Title Case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)( ([A-Z][a-zA-Z0-9]*|of|to|for|in|on|by|the|and|or|a|an))*$"

  # Every operation MUST have a description
  fixer-operation-description-required:
    description: Every operation must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy

  # Every operation MUST have at least one tag matching the declared global tags
  fixer-operation-tags-required:
    description: Every operation must declare at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  # Currency code parameters MUST follow ISO 4217 (three uppercase letters in examples)
  fixer-currency-code-example-format:
    description: Currency code examples (base/symbols/from/to) must be uppercase ISO 4217 codes.
    severity: warn
    given: $.paths[*].get.parameters[?(@.name=='base' || @.name=='from' || @.name=='to')].schema.example
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]{3}$"

  # Date parameters MUST be format: date
  fixer-date-parameter-format:
    description: Date-valued parameters must declare schema.format = 'date'.
    severity: warn
    given: $.paths[*].get.parameters[?(@.name=='date' || @.name=='start_date' || @.name=='end_date')].schema
    then:
      field: format
      function: truthy

  # Every response schema MUST include a top-level 'success' boolean (Fixer envelope convention)
  fixer-response-success-envelope:
    description: Response schemas must include a `success` boolean property.
    severity: warn
    given: $.components.schemas[?(@property!='ErrorResponse' && @property!='FluctuationEntry')].properties
    then:
      field: success
      function: truthy

  # Error responses MUST conform to the Fixer error envelope
  fixer-error-envelope:
    description: ErrorResponse schema must include success=false and a nested error object with code/type/info.
    severity: error
    given: $.components.schemas.ErrorResponse.properties
    then:
      field: error
      function: truthy

  # API key auth must be defined and referenced
  fixer-apikey-security-scheme:
    description: ApiKeyAuth security scheme must be defined as a header named 'apikey'.
    severity: error
    given: $.components.securitySchemes.ApiKeyAuth
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - type
            - in
            - name
          properties:
            type:
              const: apiKey
            in:
              const: header
            name:
              const: apikey

  # Servers should include the APILayer-hosted endpoint
  fixer-server-apilayer-required:
    description: At least one server must point at api.apilayer.com/fixer.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "api\\.apilayer\\.com/fixer"