RubyGems · API Governance Rules

RubyGems API Rules

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

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

Rule Categories

error no path query rubygems schema servers

Rules

warn
rubygems-operation-ids-camel-case
All operationIds must use camelCase naming convention.
$.paths.*[get,post,put,patch,delete].operationId
warn
rubygems-tags-title-case
All tags must use Title Case.
$.tags[*].name
warn
rubygems-api-key-auth
Authenticated endpoints must use apiKeyAuth or basicAuth security schemes.
$.components.securitySchemes
warn
rubygems-json-responses
All GET endpoints should return application/json content type.
$.paths.*.get.responses.200.content
info
rubygems-paths-snake-case-params
Query parameter names should use snake_case per RubyGems convention.
$.paths.*[get,post,delete].parameters[?(@.in=='query')].name
error
rubygems-response-200-defined
All operations must define a 200 or 201 response.
$.paths.*[get,post,put,patch,delete].responses
warn
rubygems-401-on-protected
Protected endpoints must define a 401 response.
$.paths.*[post,delete,patch].responses
warn
rubygems-summaries-title-case
Operation summaries must use Title Case.
$.paths.*[get,post,put,patch,delete].summary
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the rubygems.org domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be camelCase (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 (Error) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# rubygems — 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: 6/6 servers on rubygems.org
#   - path-params-casing: camel @ 100% (n=13)
#   - query-params-casing: snake @ 100% (n=10)
#   - operationid-casing: camel @ 100% (n=28)
#   - schema-names-casing: pascal @ 100% (n=19)
#   - schema-properties-casing: snake @ 100% (n=144)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - pagination params observed: ['page']
#   - merge: kept 8 existing, added 8 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  rubygems-operation-ids-camel-case:
    description: All operationIds must use camelCase naming convention.
    severity: warn
    given: $.paths.*[get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  rubygems-tags-title-case:
    description: All tags must use Title Case.
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9 ]*$
  rubygems-api-key-auth:
    description: Authenticated endpoints must use apiKeyAuth or basicAuth security schemes.
    severity: warn
    given: $.components.securitySchemes
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          oneOf:
          - required:
            - apiKeyAuth
          - required:
            - basicAuth
  rubygems-json-responses:
    description: All GET endpoints should return application/json content type.
    severity: warn
    given: $.paths.*.get.responses.200.content
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            application/json:
              type: object
  rubygems-paths-snake-case-params:
    description: Query parameter names should use snake_case per RubyGems convention.
    severity: info
    given: $.paths.*[get,post,delete].parameters[?(@.in=='query')].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  rubygems-response-200-defined:
    description: All operations must define a 200 or 201 response.
    severity: error
    given: $.paths.*[get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
  rubygems-401-on-protected:
    description: Protected endpoints must define a 401 response.
    severity: warn
    given: $.paths.*[post,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          required:
          - '401'
  rubygems-summaries-title-case:
    description: Operation summaries must use Title Case.
    severity: warn
    given: $.paths.*[get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]
  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 rubygems.org domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: rubygems\.org
  path-params-casing:
    description: Path parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: camel
  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 (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy