TM Forum · API Governance Rules

TM Forum API Rules

Spectral linting rules defining API design standards and conventions for TM Forum.

38 Rules error 9 warn 17 info 12
View Rules File View on GitHub

Rule Categories

delete deprecation error examples get info no openapi operation parameter path paths post query request response schema security servers tag

Rules

error
info-title-required
Info object must have a title
$.info
warn
info-description-required
Info object must have a description of at least 20 characters
$.info
error
info-version-required
Info object must have a version
$.info
warn
openapi-version-3
Specs must use OpenAPI 3.x
$
error
servers-defined
Servers array must be defined and non-empty
$
warn
servers-https
Server URLs must use HTTPS
$.servers[*].url
warn
paths-kebab-case
Path segments must use kebab-case
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not end with a trailing slash
$.paths[*]~
info
paths-versioned
Paths should include a version prefix
$.paths[*]~
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-description-required
Every operation should have a description
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-operationid-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-operationid-camel-case
OperationId must use camelCase
$.paths[*][get,post,put,patch,delete,head,options].operationId
error
operation-tags-required
Every operation must have at least one tag
$.paths[*][get,post,put,patch,delete,head,options]
info
operation-summary-tm-forum-prefix
Operation summaries should start with 'TM Forum'
$.paths[*][get,post,put,patch,delete,head,options].summary
info
tag-name-title-case
Tag names in the global tags array should use Title Case
$.tags[*].name
info
tag-description-required
All global tags should have a description
$.tags[*]
warn
parameter-description-required
All parameters must have a description
$.paths[*][get,post,put,patch,delete][parameters][*]
info
parameter-name-snake-case
Parameter names should use snake_case or camelCase
$.paths[*][get,post,put,patch,delete][parameters][*].name
warn
request-body-content-type-json
Request bodies should support application/json
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Operations must define at least one 2xx success response
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All response objects must have a description
$.paths[*][get,post,put,patch,delete].responses[*]
info
response-400-defined
Operations should define a 400 Bad Request response
$.paths[*][post,put,patch].responses
info
response-401-defined
Operations should define a 401 Unauthorized response
$.paths[*][get,post,put,patch,delete].responses
info
schema-property-camel-case
Schema property names should use camelCase
$.components.schemas[*].properties[*]~
warn
schema-type-defined
Schema properties should have a type defined
$.components.schemas[*].properties[*]
info
schema-description-required
Top-level schemas should have a description
$.components.schemas[*]
warn
security-schemes-defined
Security schemes must be defined in components
$.components
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body
$.paths[*].delete
info
post-has-request-body
POST operations creating resources should have a request body
$.paths[*].post
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
warn
deprecation-documented
Deprecated operations should have a description explaining the deprecation
$.paths[*][get,post,put,patch,delete][?(@.deprecated==true)]
info
examples-encouraged
Schema properties are encouraged to have example values
$.components.schemas[*].properties[*]
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')]
info
schema-properties-casing
Schema properties should be camelCase (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

Spectral Ruleset

Raw ↑
# tm-forum — 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: 67% of servers already https (warn)
#   - path-params-casing: snake @ 100% (n=121)
#   - query-params-casing: snake @ 100% (n=191)
#   - operationid-casing: camel @ 100% (n=335)
#   - schema-properties-casing: camel @ 47% (n=367)
#   - error-schema-defined: Error
#   - pagination params observed: ['limit', 'offset']
#   - merge: kept 34 existing, added 5 measured, upgraded 0
#   - added: path-params-casing, query-params-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info object must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: Info object must have a description of at least 20 characters
    severity: warn
    given: $.info
    then:
      field: description
      function: minLength
      functionOptions:
        value: 20
  info-version-required:
    description: Info object must have a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: Specs must use OpenAPI 3.x
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    description: Servers array must be defined and non-empty
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-kebab-case:
    description: Path segments must use kebab-case
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9{][a-z0-9-{}]*)*$
  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  paths-versioned:
    description: Paths should include a version prefix
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/v[0-9]
  operation-summary-required:
    description: Every operation must have a summary
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Every operation should have a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: description
      function: truthy
  operation-operationid-required:
    description: Every operation must have an operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: operationId
      function: truthy
  operation-operationid-camel-case:
    description: OperationId must use camelCase
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-tags-required:
    description: Every operation must have at least one tag
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: tags
      function: truthy
  operation-summary-tm-forum-prefix:
    description: Operation summaries should start with 'TM Forum'
    severity: info
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: ^TM Forum
  tag-name-title-case:
    description: Tag names in the global tags array should use Title Case
    severity: info
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]
  tag-description-required:
    description: All global tags should have a description
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  parameter-description-required:
    description: All parameters must have a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete][parameters][*]
    then:
      field: description
      function: truthy
  parameter-name-snake-case:
    description: Parameter names should use snake_case or camelCase
    severity: info
    given: $.paths[*][get,post,put,patch,delete][parameters][*].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9_.]*$
  request-body-content-type-json:
    description: Request bodies should support application/json
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
          - application/json
  response-success-required:
    description: Operations must define at least one 2xx success response
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  response-description-required:
    description: All response objects must have a description
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-400-defined:
    description: Operations should define a 400 Bad Request response
    severity: info
    given: $.paths[*][post,put,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
          - '400'
  response-401-defined:
    description: Operations should define a 401 Unauthorized response
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
          - '401'
  schema-property-camel-case:
    description: Schema property names should use camelCase
    severity: info
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9@.]*$
  schema-type-defined:
    description: Schema properties should have a type defined
    severity: warn
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - type
          - required:
            - $ref
          - required:
            - allOf
  schema-description-required:
    description: Top-level schemas should have a description
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not have a request body
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  post-has-request-body:
    description: POST operations creating resources should have a request body
    severity: info
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy
  deprecation-documented:
    description: Deprecated operations should have a description explaining the deprecation
    severity: warn
    given: $.paths[*][get,post,put,patch,delete][?(@.deprecated==true)]
    then:
      field: description
      function: truthy
  examples-encouraged:
    description: Schema properties are encouraged to have example values
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: example
      function: truthy
  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-properties-casing:
    description: Schema properties should be camelCase (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: camel
  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