Apache CouchDB · API Governance Rules

Apache CouchDB API Rules

Spectral linting rules defining API design standards and conventions for Apache CouchDB.

28 Rules error 11 warn 15 info 2
View Rules File View on GitHub

Rule Categories

delete examples get info no openapi operation parameter paths request response schema security servers tag

Rules

error
info-title-required
OpenAPI info title must be present
$.info
warn
info-description-required
OpenAPI info must have a description
$.info
error
info-version-required
OpenAPI info must include a version
$.info
warn
openapi-version-3
All specs must use OpenAPI 3.0.x
$
error
servers-required
At least one server must be defined
$
warn
servers-https
Production servers should use HTTPS
$.servers[*]
warn
paths-kebab-case
Path segments should use kebab-case (lowercase, hyphens allowed)
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not have a trailing slash
$.paths[*]~
error
operation-operationid-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camel-case
operationId should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-prefix
Operation summaries should start with "Apache CouchDB"
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
Every operation should have a description
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
tag-global-defined
All tags used in operations should be defined globally
$
warn
parameter-description-required
All parameters must have a description
$.paths[*][get,post,put,patch,delete].parameters[*]
error
parameter-schema-required
All parameters must have a schema
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
request-body-content-type
Request bodies should use application/json content type
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must have at least one 2xx response
$.paths[*][get,post,put,patch,delete].responses
warn
response-404-for-get
GET operations on resource paths should include a 404 response
$.paths[*].get.responses
error
response-description-required
All responses must have a description
$.paths[*][get,post,put,patch,delete].responses[*]
info
schema-property-description
Schema properties should have descriptions
$.components.schemas[*].properties[*]
warn
schema-type-defined
Top-level schemas should have a type defined
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined if security is declared
$
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body
$.paths[*].delete
warn
no-empty-descriptions
Descriptions must not be empty strings
$..description
info
examples-encouraged
Schema properties are encouraged to have examples
$.components.schemas[*].properties[*]

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  info-title-required:
    description: OpenAPI info title must be present
    severity: error
    given: $.info
    then:
      field: title
      function: truthy

  info-description-required:
    description: OpenAPI info must have a description
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy

  info-version-required:
    description: OpenAPI info must include a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: All specs must use OpenAPI 3.0.x
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\.0\\."

  # SERVERS
  servers-required:
    description: At least one server must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  servers-https:
    description: Production servers should use HTTPS
    severity: warn
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: "^(https://|http://localhost)"

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments should use kebab-case (lowercase, hyphens allowed)
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9_{}\\-]+)+$|^/$"

  paths-no-trailing-slash:
    description: Paths must not have a trailing slash
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

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

  operation-operationid-camel-case:
    description: operationId should use camelCase
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  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-summary-prefix:
    description: Operation summaries should start with "Apache CouchDB"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Apache CouchDB "

  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 must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  # TAGS
  tag-global-defined:
    description: All tags used in operations should be defined globally
    severity: warn
    given: $
    then:
      field: tags
      function: truthy

  # PARAMETERS
  parameter-description-required:
    description: All parameters must have a description
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: description
      function: truthy

  parameter-schema-required:
    description: All parameters must have a schema
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: schema
      function: truthy

  # REQUEST BODIES
  request-body-content-type:
    description: Request bodies should use application/json content type
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      field: application/json
      function: truthy

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

  response-404-for-get:
    description: GET operations on resource paths should include a 404 response
    severity: warn
    given: "$.paths[*].get.responses"
    then:
      field: "404"
      function: defined

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

  # SCHEMAS — PROPERTY NAMING
  schema-property-description:
    description: Schema properties should have descriptions
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  schema-type-defined:
    description: Top-level schemas should have a type defined
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined if security is declared
    severity: error
    given: $
    then:
      field: components.securitySchemes
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have a request body
    severity: error
    given: "$.paths[*].get"
    then:
      field: requestBody
      function: falsy

  delete-no-request-body:
    description: DELETE operations should not have a request body
    severity: warn
    given: "$.paths[*].delete"
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings
    severity: warn
    given: "$..description"
    then:
      function: pattern
      functionOptions:
        match: ".+"

  examples-encouraged:
    description: Schema properties are encouraged to have examples
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: example
      function: defined