Thanx · API Governance Rules

Thanx API Rules

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

40 Rules error 6 warn 24 info 10
View Rules File View on GitHub

Rule Categories

error no operationid path query schema thanx

Rules

warn
thanx-info-title
Info title should start with "Thanx".
$.info
warn
thanx-info-description
Info description is required and should be meaningful.
$.info
error
thanx-info-version
Info version is required.
$.info
info
thanx-info-contact
A contact should be present.
$.info
info
thanx-info-license
A license should be present.
$.info
warn
thanx-openapi-3-1
Specs should target OpenAPI 3.1.x.
$
error
thanx-servers-defined
At least one server must be defined.
$
error
thanx-servers-https
Server URLs must use HTTPS.
$.servers[*]
info
thanx-servers-description
Each server should have a description.
$.servers[*]
warn
thanx-paths-snake-case
Path segments should be snake_case (lowercase, underscores), matching Thanx resource paths.
$.paths[*]~
warn
thanx-paths-no-trailing-slash
Paths should not end with a trailing slash.
$.paths[*]~
error
thanx-operation-operationId
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
thanx-operation-operationId-camel-verb
operationId should be camelCase with a verb prefix (get/list/create/update/delete/issue/revoke/activate/finalize/grant/exchange).
$.paths[*][get,post,put,patch,delete]
warn
thanx-operation-summary
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
thanx-operation-summary-title-case
Operation summary should be Title Case.
$.paths[*][get,post,put,patch,delete]
info
thanx-operation-description
Every operation should have a description.
$.paths[*][get,post,put,patch,delete]
warn
thanx-operation-tags
Every operation must be tagged.
$.paths[*][get,post,put,patch,delete]
info
thanx-global-tags
A global tags array should be defined.
$
info
thanx-tag-description
Each global tag should have a description.
$.tags[*]
warn
thanx-tag-title-case
Tag names should be Title Case.
$.tags[*]
info
thanx-parameter-description
Parameters should be described.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
thanx-parameter-snake-case
Parameter names should be snake_case (array params may end in []).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in)]
warn
thanx-request-body-json
Request bodies should offer application/json.
$.paths[*][post,put,patch].requestBody.content
warn
thanx-response-success
Operations should declare a 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
thanx-response-description
Each response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
info
thanx-error-schema-message
The Error schema should expose a message or error field.
$.components.schemas.Error.properties
warn
thanx-schema-property-snake-case
Schema property names should be snake_case.
$.components.schemas[*].properties[*]~
info
thanx-schema-property-typed
Schema properties should declare a type or a $ref.
$.components.schemas[*].properties[*]
warn
thanx-global-security
A global security requirement should be defined.
$
error
thanx-security-schemes-defined
Security schemes must be defined under components.
$.components
info
thanx-security-bearer
A bearer auth scheme should be present (Thanx uses end-user access tokens).
$.components.securitySchemes
error
thanx-get-no-body
GET operations must not declare a request body.
$.paths[*].get
warn
thanx-delete-no-body
DELETE operations should not declare a request body.
$.paths[*].delete
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
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 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 ↑
# thanx — 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=9)
#   - query-params-casing: snake @ 90% (n=19)
#   - operationid-casing: camel @ 100% (n=30)
#   - schema-names-casing: pascal @ 100% (n=28)
#   - schema-properties-casing: snake @ 100% (n=142)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - pagination params observed: ['page', 'per_page']
#   - merge: kept 33 existing, added 7 measured, upgraded 0
#   - added: path-params-casing, query-params-casing, operationid-casing, schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  thanx-info-title:
    description: Info title should start with "Thanx".
    severity: warn
    given: $.info
    then:
      field: title
      function: pattern
      functionOptions:
        match: ^Thanx
  thanx-info-description:
    description: Info description is required and should be meaningful.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  thanx-info-version:
    description: Info version is required.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  thanx-info-contact:
    description: A contact should be present.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  thanx-info-license:
    description: A license should be present.
    severity: info
    given: $.info
    then:
      field: license
      function: truthy
  thanx-openapi-3-1:
    description: Specs should target OpenAPI 3.1.x.
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.1\.
  thanx-servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  thanx-servers-https:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: ^https://
  thanx-servers-description:
    description: Each server should have a description.
    severity: info
    given: $.servers[*]
    then:
      field: description
      function: truthy
  thanx-paths-snake-case:
    description: Path segments should be snake_case (lowercase, underscores), matching Thanx resource
      paths.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9_.]+(\{[a-zA-Z0-9_]+\})?|/\{[a-zA-Z0-9_]+\})+/?$|^/$
  thanx-paths-no-trailing-slash:
    description: Paths should not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  thanx-operation-operationId:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  thanx-operation-operationId-camel-verb:
    description: operationId should be camelCase with a verb prefix (get/list/create/update/delete/issue/revoke/activate/finalize/grant/exchange).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: pattern
      functionOptions:
        match: ^(get|list|create|update|delete|issue|revoke|activate|finalize|grant|exchange|upsert|check)[A-Z0-9].*$
  thanx-operation-summary:
    description: Every operation must have a summary.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  thanx-operation-summary-title-case:
    description: Operation summary should be Title Case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*( [A-Z0-9][A-Za-z0-9]*)*$
  thanx-operation-description:
    description: Every operation should have a description.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  thanx-operation-tags:
    description: Every operation must be tagged.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  thanx-global-tags:
    description: A global tags array should be defined.
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  thanx-tag-description:
    description: Each global tag should have a description.
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  thanx-tag-title-case:
    description: Tag names should be Title Case.
    severity: warn
    given: $.tags[*]
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*( [A-Z0-9][A-Za-z0-9]*)*$
  thanx-parameter-description:
    description: Parameters should be described.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  thanx-parameter-snake-case:
    description: Parameter names should be snake_case (array params may end in []).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in)]
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*(\[\])?$
  thanx-request-body-json:
    description: Request bodies should offer application/json.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  thanx-response-success:
    description: Operations should declare a 2xx response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            ^2[0-9][0-9]$: true
          minProperties: 1
  thanx-response-description:
    description: Each response must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  thanx-error-schema-message:
    description: The Error schema should expose a message or error field.
    severity: info
    given: $.components.schemas.Error.properties
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - message
          - required:
            - error
  thanx-schema-property-snake-case:
    description: Schema property names should be snake_case.
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  thanx-schema-property-typed:
    description: Schema properties should declare a type or a $ref.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - type
          - required:
            - $ref
          - required:
            - allOf
          - required:
            - oneOf
          - required:
            - anyOf
  thanx-global-security:
    description: A global security requirement should be defined.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  thanx-security-schemes-defined:
    description: Security schemes must be defined under components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  thanx-security-bearer:
    description: A bearer auth scheme should be present (Thanx uses end-user access tokens).
    severity: info
    given: $.components.securitySchemes
    then:
      field: bearerAuth
      function: truthy
  thanx-get-no-body:
    description: GET operations must not declare a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  thanx-delete-no-body:
    description: DELETE operations should not declare a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  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
  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 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