Wikipedia / MediaWiki · API Governance Rules

Wikipedia / MediaWiki API Rules

Spectral linting rules defining API design standards and conventions for Wikipedia / MediaWiki.

29 Rules error 8 warn 16 info 5
View Rules File View on GitHub

Rule Categories

error info no openapi operation operationid parameter path query request response schema security server servers tags user

Rules

warn
info-title-prefix
Spec title should begin with "Wikipedia", "MediaWiki", "Wikimedia", or "Wikidata".
$.info
error
info-description-required
info.description must be present and non-trivial.
$.info
warn
info-license-required
info.license must be defined (CC BY-SA, CC0, or commercial).
$.info
error
openapi-version-3
OpenAPI version must be 3.x.
$.openapi
error
servers-required
At least one server must be declared.
$
warn
server-https
Servers must use https://.
$.servers[*].url
warn
path-no-trailing-slash
Paths should not end with a trailing slash.
$.paths
warn
path-snake-or-kebab
Path segments should use snake_case or kebab-case (lowercase, digits, dashes, underscores, or templated params).
$.paths
error
operation-operationid-required
Every operation must have a camelCase operationId.
$.paths[*][get,post,put,patch,delete]
error
operation-summary-required
Every operation must have a summary in Title Case prefixed with the provider name.
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
operation-microcks-extension
Every operation should declare x-microcks-operation for mock-server compatibility.
$.paths[*][get,post,put,patch,delete]
info
tags-title-case
Tag names should be Title Case (multi-word) or PascalCase.
$.tags[*].name
warn
parameter-description-required
Every parameter should have a description.
$.paths[*][*].parameters[*]
error
parameter-schema-required
Every parameter must have a schema with a type.
$.paths[*][*].parameters[*]
info
parameter-snake-case
Query and path parameters should use snake_case.
$.paths[*][*].parameters[?(@.in=='query' || @.in=='path')]
error
request-body-content-required
Request bodies must declare a content media type.
$.paths[*][post,put,patch].requestBody
error
response-success-required
Every operation must declare at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-description-required
Every response must have a description.
$.paths[*][*].responses[*]
info
schema-property-snake-case
Schema properties should use snake_case (MediaWiki convention).
$.components.schemas[*].properties
warn
schema-type-required
Each top-level component schema should declare a type.
$.components.schemas[*]
warn
security-schemes-defined
Security schemes should be defined in components.
$.components
warn
no-empty-description
Descriptions must not be empty when present.
$..description
info
user-agent-required-note
API description should mention contactable User-Agent requirement (Wikimedia policy).
$.info
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
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
warn
schema-names-casing
Component schema names should be snake_case (the dominant convention in this API).
$.components.schemas
warn
error-schema-defined
A shared error schema (ActionApiError) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# wikipedia — 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=128)
#   - query-params-casing: snake @ 100% (n=81)
#   - operationid-casing: camel @ 88% (n=34)
#   - schema-names-casing: snake @ 77% (n=83)
#   - schema-properties-casing: snake @ 98% (n=376)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ActionApiError
#   - pagination params observed: ['count', 'limit']
#   - merge: kept 25 existing, added 5 measured, upgraded 0
#   - added: query-params-casing, operationid-casing, schema-names-casing, security-schemes-defined, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-prefix:
    description: Spec title should begin with "Wikipedia", "MediaWiki", "Wikimedia", or "Wikidata".
    message: 'info.title should start with one of: Wikipedia, MediaWiki, Wikimedia, Wikidata.'
    given: $.info
    severity: warn
    then:
      field: title
      function: pattern
      functionOptions:
        match: ^(Wikipedia|MediaWiki|Wikimedia|Wikidata)\b
  info-description-required:
    description: info.description must be present and non-trivial.
    given: $.info
    severity: error
    then:
      field: description
      function: truthy
  info-license-required:
    description: info.license must be defined (CC BY-SA, CC0, or commercial).
    given: $.info
    severity: warn
    then:
      field: license
      function: truthy
  openapi-version-3:
    description: OpenAPI version must be 3.x.
    given: $.openapi
    severity: error
    then:
      function: pattern
      functionOptions:
        match: ^3\.
  servers-required:
    description: At least one server must be declared.
    given: $
    severity: error
    then:
      field: servers
      function: truthy
  server-https:
    description: Servers must use https://.
    given: $.servers[*].url
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^https://
  path-no-trailing-slash:
    description: Paths should not end with a trailing slash.
    given: $.paths
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: .+/$
  path-snake-or-kebab:
    description: Path segments should use snake_case or kebab-case (lowercase, digits, dashes, underscores,
      or templated params).
    given: $.paths
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9_\-]+|/\{[A-Za-z_]+\})+$|^/$|^/api\.php$|^/sparql$
  operation-operationid-required:
    description: Every operation must have a camelCase operationId.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
    - field: operationId
      function: truthy
    - field: operationId
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-summary-required:
    description: Every operation must have a summary in Title Case prefixed with the provider name.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Every operation must have a description.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Every operation must have at least one tag.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: tags
      function: truthy
  operation-microcks-extension:
    description: Every operation should declare x-microcks-operation for mock-server compatibility.
    given: $.paths[*][get,post,put,patch,delete]
    severity: info
    then:
      field: x-microcks-operation
      function: truthy
  tags-title-case:
    description: Tag names should be Title Case (multi-word) or PascalCase.
    given: $.tags[*].name
    severity: info
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9 ]*$
  parameter-description-required:
    description: Every parameter should have a description.
    given: $.paths[*][*].parameters[*]
    severity: warn
    then:
      field: description
      function: truthy
  parameter-schema-required:
    description: Every parameter must have a schema with a type.
    given: $.paths[*][*].parameters[*]
    severity: error
    then:
      field: schema
      function: truthy
  parameter-snake-case:
    description: Query and path parameters should use snake_case.
    given: $.paths[*][*].parameters[?(@.in=='query' || @.in=='path')]
    severity: info
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$|^[A-Z][A-Za-z]+$
  request-body-content-required:
    description: Request bodies must declare a content media type.
    given: $.paths[*][post,put,patch].requestBody
    severity: error
    then:
      field: content
      function: truthy
  response-success-required:
    description: Every operation must declare at least one 2xx response.
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: error
    then:
      function: truthy
  response-description-required:
    description: Every response must have a description.
    given: $.paths[*][*].responses[*]
    severity: warn
    then:
      field: description
      function: truthy
  schema-property-snake-case:
    description: Schema properties should use snake_case (MediaWiki convention).
    given: $.components.schemas[*].properties
    severity: info
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$|^\*$|^[A-Z][A-Za-z]*$|^[a-z][a-zA-Z0-9]*$|^xml:lang$
  schema-type-required:
    description: Each top-level component schema should declare a type.
    given: $.components.schemas[*]
    severity: warn
    then:
      field: type
      function: truthy
  security-schemes-defined:
    description: Security schemes should be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  no-empty-description:
    description: Descriptions must not be empty when present.
    given: $..description
    severity: warn
    then:
      function: truthy
  user-agent-required-note:
    description: API description should mention contactable User-Agent requirement (Wikimedia policy).
    given: $.info
    severity: info
    then:
      field: description
      function: pattern
      functionOptions:
        match: (?i)User[- ]Agent
  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
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: casing
      functionOptions:
        type: camel
  schema-names-casing:
    description: Component schema names should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (ActionApiError) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ActionApiError
      function: truthy