Stability AI · API Governance Rules

Stability AI API Rules

Spectral linting rules defining API design standards and conventions for Stability AI.

10 Rules error 2 warn 7 info 1
View Rules File View on GitHub

Rule Categories

stability

Rules

warn
stability-ai-operation-summaries-title-case
All Stability AI API operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
error
stability-ai-bearer-auth-required
All Stability AI API operations must require bearer authentication
$.components.securitySchemes
warn
stability-ai-multipart-form-data
Stability AI image operations should use multipart/form-data request bodies
$.paths[*].post.requestBody.content
warn
stability-ai-v2beta-paths
Stability AI API paths should use the /v2beta prefix
$.paths[*]~
warn
stability-ai-operationid-camel-case
Stability AI operationIds must use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
stability-ai-operations-must-have-operationid
All Stability AI API operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
stability-ai-error-responses
Stability AI API operations must define 400 and 401 error responses
$.paths[*][get,post,put,patch,delete].responses
warn
stability-ai-output-format-parameter
Stability AI image generation requests should support output_format parameter
$.components.schemas[*].properties
warn
stability-ai-response-supports-binary
Stability AI image generation responses should support binary image output
$.paths[*].post.responses.200.content
info
stability-ai-seed-parameter
Stability AI generation requests should support a seed parameter for reproducibility
$.components.schemas[*].properties

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  stability-ai-operation-summaries-title-case:
    description: All Stability AI API operation summaries must use Title Case
    message: "Operation summary '{{value}}' 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]*)*$"

  stability-ai-bearer-auth-required:
    description: All Stability AI API operations must require bearer authentication
    message: "Stability AI API operations must use bearerAuth security scheme"
    severity: error
    given: "$.components.securitySchemes"
    then:
      field: bearerAuth
      function: truthy

  stability-ai-multipart-form-data:
    description: Stability AI image operations should use multipart/form-data request bodies
    message: "Image generation/editing operations should use multipart/form-data encoding"
    severity: warn
    given: "$.paths[*].post.requestBody.content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  stability-ai-v2beta-paths:
    description: Stability AI API paths should use the /v2beta prefix
    message: "Path '{{value}}' should start with /v2beta"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/v2beta/"

  stability-ai-operationid-camel-case:
    description: Stability AI operationIds must use camelCase
    message: "operationId '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  stability-ai-operations-must-have-operationid:
    description: All Stability AI API operations must have an operationId
    message: "Operation is missing operationId"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  stability-ai-error-responses:
    description: Stability AI API operations must define 400 and 401 error responses
    message: "Operation should define 400 and 401 error responses"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - '400'
            - '401'

  stability-ai-output-format-parameter:
    description: Stability AI image generation requests should support output_format parameter
    message: "Image request schema should include output_format property"
    severity: warn
    given: "$.components.schemas[*].properties"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  stability-ai-response-supports-binary:
    description: Stability AI image generation responses should support binary image output
    message: "Image operations should return image/jpeg or image/png responses"
    severity: warn
    given: "$.paths[*].post.responses.200.content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  stability-ai-seed-parameter:
    description: Stability AI generation requests should support a seed parameter for reproducibility
    message: "Generation request schema should include a seed parameter"
    severity: info
    given: "$.components.schemas[*].properties"
    then:
      function: schema
      functionOptions:
        schema:
          type: object