WanAPIs · API Governance Rules

WanAPIs API Rules

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

7 Rules error 3 warn 4
View Rules File View on GitHub

Rule Categories

wanapis

Rules

error
wanapis-server-base-url
Servers must use the documented WanAPIs OpenAI-compatible base URL.
$.servers[*]
error
wanapis-bearer-auth-required
Every operation must inherit bearer auth (global security or operation-level).
$
warn
wanapis-operation-id-camelcase
operationId should be camelCase (e.g. createChatCompletion).
$.paths[*][*].operationId
error
wanapis-tag-required
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
wanapis-response-schema-required
2xx responses must declare an application/json or audio schema.
$.paths[*][*].responses['200'].content
warn
wanapis-error-schema
4xx/5xx responses should reference the Error schema.
$.paths[*][*].responses[?(@property.match(/^(4|5)\\d{2}$/))]
warn
wanapis-model-parameter
Request bodies for inference endpoints must include a `model` field.
$.components.schemas[?(@property.match(/Request$/))]

Spectral Ruleset

wanapis-rules.yml Raw ↑
extends:
  - spectral:oas
formats:
  - oas3_1
rules:
  # WanAPIs is OpenAI-compatible; enforce the conventions that matter for the
  # gateway: bearer auth on every operation, /v1 prefix on the server, and
  # consistent OpenAI-style JSON shapes.

  wanapis-server-base-url:
    description: Servers must use the documented WanAPIs OpenAI-compatible base URL.
    severity: error
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: '^https://api\.wanapis\.com/v1$'

  wanapis-bearer-auth-required:
    description: Every operation must inherit bearer auth (global security or operation-level).
    severity: error
    given: $
    then:
      field: components.securitySchemes.bearerAuth
      function: truthy

  wanapis-operation-id-camelcase:
    description: operationId should be camelCase (e.g. createChatCompletion).
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]+$'

  wanapis-tag-required:
    description: Every operation must declare at least one tag.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: length
      functionOptions: { min: 1 }

  wanapis-response-schema-required:
    description: 2xx responses must declare an application/json or audio schema.
    severity: warn
    given: $.paths[*][*].responses['200'].content
    then:
      function: truthy

  wanapis-error-schema:
    description: 4xx/5xx responses should reference the Error schema.
    severity: warn
    given: $.paths[*][*].responses[?(@property.match(/^(4|5)\\d{2}$/))]
    then:
      field: $ref
      function: pattern
      functionOptions:
        match: 'Error'

  wanapis-model-parameter:
    description: Request bodies for inference endpoints must include a `model` field.
    severity: warn
    given: $.components.schemas[?(@property.match(/Request$/))]
    then:
      field: required
      function: schema
      functionOptions:
        schema:
          type: array
          contains: { const: model }