AIMLAPI · API Governance Rules

AIMLAPI API Rules

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

15 Rules error 6 warn 8 info 1
View Rules File View on GitHub

Rule Categories

info no openai operation parameter response schema security servers

Rules

warn
info-title-aimlapi
Title should start with AIMLAPI
$.info.title
warn
operation-summary-prefix
Operation summaries must start with "AIMLAPI"
$.paths[*][get,post,put,patch,delete].summary
error
operation-id-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation should have a description
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation should have tags
$.paths[*][get,post,put,patch,delete]
error
servers-https
Server URLs must use HTTPS
$.servers[*].url
error
response-success-required
Operations must define at least one 2xx response
$.paths[*][get,post,put,patch,delete].responses
warn
parameter-description
Parameters should have descriptions
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
schema-property-type
Schema properties should have types defined
$.components.schemas[*].properties[*]
warn
security-bearer-defined
Bearer auth security scheme should be defined
$.components.securitySchemes
error
info-description-required
API must have a description
$.info
error
info-version-required
API must have a version
$.info
warn
no-empty-descriptions
Descriptions must not be empty
$..description
info
openai-compatible-model-param
Chat completion operations should have a model parameter
$.paths['/chat/completions'].post

Spectral Ruleset

Raw ↑
extends: "spectral:oas"

rules:
  info-title-aimlapi:
    description: Title should start with AIMLAPI
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^AIMLAPI"

  operation-summary-prefix:
    description: Operation summaries must start with "AIMLAPI"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^AIMLAPI"

  operation-id-required:
    description: Every operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: operationId
      function: truthy

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

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

  operation-tags-required:
    description: Every operation should have tags
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  servers-https:
    description: Server URLs must use HTTPS
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  response-success-required:
    description: Operations must define at least one 2xx response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
            - required: ["200"]
            - required: ["201"]
            - required: ["204"]

  parameter-description:
    description: Parameters should have descriptions
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: description
      function: truthy

  schema-property-type:
    description: Schema properties should have types defined
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: type
      function: truthy

  security-bearer-defined:
    description: Bearer auth security scheme should be defined
    severity: warn
    given: "$.components.securitySchemes"
    then:
      function: truthy

  info-description-required:
    description: API must have a description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    description: API must have a version
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  no-empty-descriptions:
    description: Descriptions must not be empty
    severity: warn
    given: "$..description"
    then:
      function: truthy

  openai-compatible-model-param:
    description: Chat completion operations should have a model parameter
    severity: info
    given: "$.paths['/chat/completions'].post"
    then:
      field: requestBody
      function: truthy