target · API Governance Rules

target API Rules

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

21 Rules error 4 warn 16 info 1
View Rules File View on GitHub

Rule Categories

error no operation path query schema servers target

Rules

warn
target-operation-ids-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
target-tags-title-case
Tags must use Title Case
$.tags[*].name
warn
target-path-kebab-case
Path segments must use kebab-case
$.paths[*]~
warn
target-paths-versioned
All paths must include a version prefix (e.g., /v1/, /v3/)
$.paths[*]~
error
target-operation-summary-exists
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
target-operation-description-exists
All operations must have a description
$.paths[*][get,post,put,patch,delete]
error
target-responses-200-exists
All operations must have a 200 response
$.paths[*][get,post,put,patch,delete].responses
warn
target-responses-401-exists
Secured operations must document 401 response
$.paths[*][get,post,put,patch,delete].responses
warn
target-parameters-description
All parameters must have descriptions
$.paths[*][*].parameters[*]
error
target-bearer-auth-defined
bearerAuth security scheme must be defined
$.components.securitySchemes
warn
target-info-contact
API must include contact information
$.info
info
target-schema-properties-described
Schema properties should have descriptions
$.components.schemas[*].properties[*]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the target.com 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
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
operation-documents-429
Operations should document a 429 response (documented on 89% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# target — 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: 1/1 servers on target.com
#   - path-params-casing: snake @ 100% (n=4)
#   - query-params-casing: snake @ 100% (n=30)
#   - operationid-casing: camel @ 100% (n=9)
#   - schema-names-casing: pascal @ 100% (n=18)
#   - schema-properties-casing: snake @ 100% (n=81)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - operation-documents-401: 89% adherence
#   - operation-documents-429: 89% adherence
#   - pagination params observed: ['limit', 'offset']
#   - merge: kept 12 existing, added 9 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, operation-documents-429, no-empty-descriptions
extends:
  - spectral:oas
rules:
  target-operation-ids-camel-case:
    description: Operation IDs must use camelCase
    message: operationId '{{value}}' must use camelCase
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  target-tags-title-case:
    description: Tags must use Title Case
    message: Tag '{{value}}' must use Title Case
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9 ]*$
  target-path-kebab-case:
    description: Path segments must use kebab-case
    message: 'Path segment must use kebab-case: {{path}}'
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9{}-]+)*$
  target-paths-versioned:
    description: All paths must include a version prefix (e.g., /v1/, /v3/)
    message: Path '{{value}}' must include a version prefix like /v1/ or /v3/
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/[a-z]+/v[0-9]+
  target-operation-summary-exists:
    description: All operations must have a summary
    message: Operation at '{{path}}' is missing a summary
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  target-operation-description-exists:
    description: All operations must have a description
    message: Operation at '{{path}}' is missing a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  target-responses-200-exists:
    description: All operations must have a 200 response
    message: Operation at '{{path}}' must define a 200 response
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  target-responses-401-exists:
    description: Secured operations must document 401 response
    message: Operation at '{{path}}' should define a 401 response
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  target-parameters-description:
    description: All parameters must have descriptions
    message: Parameter '{{value}}' is missing a description
    severity: warn
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  target-bearer-auth-defined:
    description: bearerAuth security scheme must be defined
    message: bearerAuth security scheme must be defined in components.securitySchemes
    severity: error
    given: $.components.securitySchemes
    then:
      field: bearerAuth
      function: truthy
  target-info-contact:
    description: API must include contact information
    message: API info must include contact details
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  target-schema-properties-described:
    description: Schema properties should have descriptions
    message: Schema property at '{{path}}' should have a description
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  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 target.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: target\.com
  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 (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy
  operation-documents-429:
    description: Operations should document a 429 response (documented on 89% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '429'
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy