WildApricot · API Governance Rules

WildApricot API Rules

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

26 Rules error 11 warn 11 info 4
View Rules File View on GitHub

Rule Categories

get info no openapi operation parameter paths post request response schema security servers tags

Rules

error
info-title-required
API info must have a title
$.info
warn
info-description-required
API info must have a description
$.info
error
info-version-required
API info must have a version
$.info
warn
info-contact-required
API info should have contact information
$.info
error
openapi-version-3
All WildApricot specs must use OpenAPI 3.x
$
error
servers-defined
Servers array must be defined
$
error
servers-https
Server URLs must use HTTPS
$.servers[*].url
info
paths-account-prefix
WildApricot paths should use /accounts/{accountId}/ prefix
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not end with a trailing slash
$.paths[*]~
error
operation-summary-required
All operations must have a summary
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-description-required
All operations should have a description
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,patch,delete,head,options]
info
operation-summary-wildapricot-prefix
Operation summaries should start with "WildApricot"
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
operation-tags-required
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete,head,options]
warn
tags-global-defined
Global tags array must be defined
$
info
parameter-account-id-path
Path parameters named accountId should use path-level definition
$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'accountId')]
warn
parameter-description-required
All parameters must have a description
$.paths[*][get,post,put,patch,delete].parameters[*]
error
request-body-content-required
Request bodies must define content
$.paths[*][post,put,patch].requestBody
error
response-success-required
Every operation must define at least one 2xx response
$.paths[*][get,post,put,patch,delete]
error
response-description-required
All responses must have a description
$.paths[*][get,post,put,patch,delete].responses[*]
info
schema-description-required
Top-level schemas should have descriptions
$.components.schemas[*]
warn
security-schemes-defined
Security schemes must be defined for OAuth2
$.components
warn
operation-security-defined
Operations should define security requirements
$.paths[*][get,post,put,patch,delete]
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
post-returns-2xx
POST operations should return 200 or 201
$.paths[*].post
warn
no-empty-descriptions
Descriptions must not be empty strings
$..description

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-required:
    description: API info must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy

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

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

  info-contact-required:
    description: API info should have contact information
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy

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

  # SERVERS
  servers-defined:
    description: Servers array must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy

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

  # PATHS — NAMING CONVENTIONS
  paths-account-prefix:
    description: WildApricot paths should use /accounts/{accountId}/ prefix
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: "^/(accounts|rpc)/"

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

  # OPERATIONS
  operation-summary-required:
    description: All operations must have a summary
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: summary
      function: truthy

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

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

  operation-summary-wildapricot-prefix:
    description: Operation summaries should start with "WildApricot"
    severity: info
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: "^WildApricot "

  operation-tags-required:
    description: All operations must have at least one tag
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: tags
      function: truthy

  # TAGS
  tags-global-defined:
    description: Global tags array must be defined
    severity: warn
    given: $
    then:
      field: tags
      function: truthy

  # PARAMETERS
  parameter-account-id-path:
    description: Path parameters named accountId should use path-level definition
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'accountId')]
    then:
      field: in
      function: pattern
      functionOptions:
        match: "^path$"

  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

  # REQUEST BODIES
  request-body-content-required:
    description: Request bodies must define content
    severity: error
    given: $.paths[*][post,put,patch].requestBody
    then:
      field: content
      function: truthy

  # RESPONSES
  response-success-required:
    description: Every operation must define at least one 2xx response
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: truthy

  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
  schema-description-required:
    description: Top-level schemas should have descriptions
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined for OAuth2
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy

  operation-security-defined:
    description: Operations should define security requirements
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      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

  post-returns-2xx:
    description: POST operations should return 200 or 201
    severity: warn
    given: $.paths[*].post
    then:
      field: responses
      function: truthy

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