R · API Governance Rules

R API Rules

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

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

Rule Categories

no path r schema servers

Rules

warn
r-operation-summary-title-case
All operation summaries must use Title Case
$.paths[*][*].summary
warn
r-tags-title-case
All tags must use Title Case
$.paths[*][*].tags[*]
warn
r-operation-ids-must-be-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
r-paths-kebab-case
Path segments must use kebab-case
$.paths[*]~
error
r-responses-must-include-success
All operations must define at least one 2xx response
$.paths[*][get,post,put,patch,delete]
warn
r-parameters-must-have-descriptions
All parameters must have descriptions
$.paths[*][*].parameters[*]
warn
r-components-schemas-pascal-case
Schema component names must use PascalCase
$.components.schemas[*]~
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the r-pkg.org domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# r — 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)
#   - servers-expected-domain: 3/3 servers on r-pkg.org
#   - path-params-casing: snake @ 100% (n=11)
#   - operationid-casing: camel @ 100% (n=14)
#   - schema-names-casing: pascal @ 100% (n=10)
#   - schema-properties-casing: snake @ 68% (n=40)
#   - pagination params observed: ['limit']
#   - merge: kept 7 existing, added 6 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, schema-names-casing, schema-properties-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  r-operation-summary-title-case:
    description: All operation summaries must use Title Case
    message: Operation summary '{{value}}' must use Title Case
    severity: warn
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9]*(\s[A-Z][a-zA-Z0-9]*)*$
  r-tags-title-case:
    description: All tags must use Title Case
    message: Tag '{{value}}' must use Title Case
    severity: warn
    given: $.paths[*][*].tags[*]
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9]*(\s[A-Z][a-zA-Z0-9]*)*$
  r-operation-ids-must-be-camel-case:
    description: Operation IDs must use camelCase
    message: Operation ID '{{value}}' must use camelCase
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  r-paths-kebab-case:
    description: Path segments must use kebab-case
    message: Path segment must use kebab-case (no underscores or uppercase)
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: '[A-Z_]'
  r-responses-must-include-success:
    description: All operations must define at least one 2xx response
    message: Operation must define a 2xx success response
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  r-parameters-must-have-descriptions:
    description: All parameters must have descriptions
    message: Parameter '{{value}}' must have a description
    severity: warn
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  r-components-schemas-pascal-case:
    description: Schema component names must use PascalCase
    message: Schema name '{{value}}' must use PascalCase
    severity: warn
    given: $.components.schemas[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9]*$
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the r-pkg.org domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: r\-pkg\.org
  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
  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: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy