WordPress · API Governance Rules

WordPress API Rules

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

46 Rules error 10 warn 23 info 13
View Rules File View on GitHub

Rule Categories

delete error get info no openapi operation pagination parameter path paths post query request response schema security servers tag tags

Rules

warn
info-title-wordpress-prefix
$.info.title
error
info-description-required
$.info
error
info-version-required
$.info
warn
info-contact-required
$.info
warn
info-license-required
$.info
error
openapi-version-3
$.openapi
error
servers-defined
$
warn
servers-https-only
$.servers[*].url
warn
paths-kebab-case
$.paths[*]~
warn
paths-no-trailing-slash
$.paths[*]~
info
paths-version-prefix
$.paths[*]~
error
operation-summary-required
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
$.paths[*][get,post,put,patch,delete]
warn
operation-id-camel-case
$.paths[*][get,post,put,patch,delete].operationId
warn
operation-tags-required
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-wordpress-prefix
$.paths[*][get,post,put,patch,delete].summary
info
tags-defined
$
info
tag-description-required
$.tags[*]
warn
parameter-description-required
$.paths[*][get,post,put,patch,delete].parameters[*]
info
parameter-snake-case
$.paths[*][get,post,put,patch,delete].parameters[*].name
error
parameter-schema-required
$.paths[*][get,post,put,patch,delete].parameters[*]
info
request-body-description
$.paths[*][post,put,patch].requestBody
warn
request-body-json-content
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
$.paths[*][get,post,put,patch,delete].responses[*]
info
response-401-for-auth
$.paths[*][post,put,delete].responses
info
response-404-for-get-by-id
$.paths[*~'\\{id\\}'][get].responses
warn
schema-description-required
$.components.schemas[*]
warn
schema-type-defined
$.components.schemas[*]
info
schema-property-snake-case
$.components.schemas[*].properties[*]~
info
schema-property-description
$.components.schemas[*].properties[*]
info
schema-property-example
$.components.schemas[*].properties[*]
warn
security-schemes-defined
$.components
warn
security-scheme-description
$.components.securitySchemes[*]
error
get-no-request-body
$.paths[*].get
warn
delete-no-request-body
$.paths[*].delete
info
post-should-have-request-body
$.paths[*].post
info
operation-microcks-extension
$.paths[*][get,post,put,patch,delete]
warn
no-empty-descriptions
$..description
info
pagination-parameters-standard
$.paths[*][get].parameters[?(@.name == 'limit')]
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# wordpress — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - path-params-casing: snake @ 100% (n=6)
#   - query-params-casing: snake @ 100% (n=43)
#   - operationid-casing: camel @ 100% (n=24)
#   - schema-names-casing: pascal @ 100% (n=19)
#   - schema-properties-casing: snake @ 100% (n=146)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ErrorResponse
#   - pagination params observed: ['page', 'per_page']
#   - merge: kept 41 existing, added 5 measured, upgraded 0
#   - added: path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-wordpress-prefix:
    message: API title must begin with "WordPress"
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^WordPress
  info-description-required:
    message: Info object must have a non-empty description
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    message: Info object must have a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    message: Info object should have contact information
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  info-license-required:
    message: Info object should have license information
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  openapi-version-3:
    message: Must use OpenAPI 3.0.x
    severity: error
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.0\.
  servers-defined:
    message: At least one server must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https-only:
    message: Server URLs must use HTTPS
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-kebab-case:
    message: Path segments must use kebab-case
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9{][a-z0-9\-._{}]*)*$
  paths-no-trailing-slash:
    message: Paths must not end with a trailing slash
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  paths-version-prefix:
    message: WordPress REST API paths should start with /wp/v2/
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/wp/v[0-9]+/
  operation-summary-required:
    message: Operations must have a summary
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-description-required:
    message: Operations must have a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-id-required:
    message: Operations must have an operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-id-camel-case:
    message: operationId must use camelCase
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-tags-required:
    message: Operations must have at least one tag
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  operation-summary-wordpress-prefix:
    message: Operation summaries must start with "WordPress"
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^WordPress
  tags-defined:
    message: Global tags array must be defined
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  tag-description-required:
    message: Tags must have a description
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  parameter-description-required:
    message: Parameters must have a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-snake-case:
    message: Parameter names should use snake_case
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-schema-required:
    message: Parameters must have a schema
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: schema
      function: truthy
  request-body-description:
    message: Request bodies should have a description
    severity: info
    given: $.paths[*][post,put,patch].requestBody
    then:
      field: description
      function: truthy
  request-body-json-content:
    message: Request bodies should use application/json content type
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-success-required:
    message: Operations must have a success response (2xx)
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '204'
  response-description-required:
    message: All responses must have a description
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-401-for-auth:
    message: Authenticated endpoints should document 401 response
    severity: info
    given: $.paths[*][post,put,delete].responses
    then:
      field: '401'
      function: truthy
  response-404-for-get-by-id:
    message: GET by ID endpoints should document 404 response
    severity: info
    given: $.paths[*~'\\{id\\}'][get].responses
    then:
      field: '404'
      function: truthy
  schema-description-required:
    message: Top-level schemas must have a description
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-type-defined:
    message: Schemas must have a type defined
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  schema-property-snake-case:
    message: Schema properties should use snake_case
    severity: info
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  schema-property-description:
    message: Schema properties should have descriptions
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  schema-property-example:
    message: Schema properties should have examples
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: example
      function: truthy
  security-schemes-defined:
    message: Security schemes must be defined in components
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-scheme-description:
    message: Security schemes must have a description
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy
  get-no-request-body:
    message: GET operations must not have a request body
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    message: DELETE operations should not have a request body
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  post-should-have-request-body:
    message: POST operations creating resources should have a request body
    severity: info
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy
  operation-microcks-extension:
    message: Operations should have x-microcks-operation extension for mock compatibility
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  no-empty-descriptions:
    message: Descriptions must not be empty strings
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  pagination-parameters-standard:
    message: Pagination parameters should use page and per_page (WordPress convention)
    severity: info
    given: $.paths[*][get].parameters[?(@.name == 'limit')]
    then:
      function: undefined
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy