Trelica · API Governance Rules

Trelica API Rules

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

21 Rules error 3 warn 13 info 5
View Rules File View on GitHub

Rule Categories

no path query schema security servers trelica

Rules

warn
trelica-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
trelica-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
info
trelica-pagination-cursor-pattern
List operations should support cursor-based pagination with 'after' parameter
$.paths[*].get
info
trelica-limit-parameter
List operations should include a limit parameter
$.paths[*].get.parameters[*]
error
trelica-security-defined
All operations must define security requirements
$.paths[*][get,post,put,patch,delete]
error
trelica-response-200-defined
All GET operations must define a 200 response
$.paths[*].get
warn
trelica-response-401-defined
Operations using OAuth must define a 401 response
$.paths[*][get,post,put,patch,delete]
warn
trelica-tag-defined
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
trelica-path-kebab-case
API paths must use kebab-case
$.paths[*]~
warn
trelica-versioned-paths
API paths should include a version segment (v1, v2, etc.)
$.paths[*]~
info
trelica-scim-users-separate-pagination
SCIM endpoints use startIndex/count pagination, not cursor-based
$.paths['/scim/v2/Users'].get
warn
trelica-request-body-post
POST operations should define a request body
$.paths[*].post
info
trelica-since-filter-datetime
The 'since' filter parameter should be ISO 8601 date-time format
$.paths[*][*].parameters[?(@.name=='since')].schema
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the trelica.com 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
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
security-schemes-defined
Security schemes should be defined in components.
$.components
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# trelica — 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: 2/2 servers on trelica.com
#   - path-params-casing: camel @ 100% (n=5)
#   - query-params-casing: snake @ 97% (n=31)
#   - operationid-casing: camel @ 100% (n=13)
#   - schema-names-casing: pascal @ 100% (n=10)
#   - schema-properties-casing: snake @ 57% (n=74)
#   - security: global (root) — NOT emitting operation-security-required
#   - pagination params observed: ['count', 'limit']
#   - merge: kept 13 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, security-schemes-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  trelica-operation-id-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]*$
  trelica-operation-summary-title-case:
    description: Operation summaries must use Title Case
    message: Summary '{{value}}' should use Title Case
    severity: warn
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9 ()-]*$
  trelica-pagination-cursor-pattern:
    description: List operations should support cursor-based pagination with 'after' parameter
    message: List operations should include 'after' pagination cursor parameter
    severity: info
    given: $.paths[*].get
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            parameters:
              type: array
  trelica-limit-parameter:
    description: List operations should include a limit parameter
    message: List endpoints should support a 'limit' query parameter
    severity: info
    given: $.paths[*].get.parameters[*]
    then:
      function: schema
      functionOptions:
        schema:
          type: object
  trelica-security-defined:
    description: All operations must define security requirements
    message: Operation '{{path}}' must define security requirements
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: defined
  trelica-response-200-defined:
    description: All GET operations must define a 200 response
    message: GET operation must define a 200 success response
    severity: error
    given: $.paths[*].get
    then:
      field: responses.200
      function: defined
  trelica-response-401-defined:
    description: Operations using OAuth must define a 401 response
    message: Authenticated operation should define a 401 Unauthorized response
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses.401
      function: defined
  trelica-tag-defined:
    description: All operations must have at least one tag
    message: Operation must include at least one tag
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: defined
  trelica-path-kebab-case:
    description: API paths must use kebab-case
    message: Path '{{path}}' should use kebab-case segments
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9][a-z0-9-]*(/[a-z0-9][a-z0-9-]*|/\{[a-zA-Z][a-zA-Z0-9]*\})*)+$
  trelica-versioned-paths:
    description: API paths should include a version segment (v1, v2, etc.)
    message: Path '{{path}}' should include a version segment
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/[a-z]+/v[0-9]
  trelica-scim-users-separate-pagination:
    description: SCIM endpoints use startIndex/count pagination, not cursor-based
    message: SCIM endpoints use startIndex and count parameters
    severity: info
    given: $.paths['/scim/v2/Users'].get
    then:
      function: defined
  trelica-request-body-post:
    description: POST operations should define a request body
    message: POST operation should include a requestBody
    severity: warn
    given: $.paths[*].post
    then:
      field: requestBody
      function: defined
  trelica-since-filter-datetime:
    description: The 'since' filter parameter should be ISO 8601 date-time format
    message: 'Parameter ''since'' should use format: date-time'
    severity: info
    given: $.paths[*][*].parameters[?(@.name=='since')].schema
    then:
      field: format
      function: enumeration
      functionOptions:
        values:
        - date-time
  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 trelica.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: trelica\.com
  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: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  security-schemes-defined:
    description: Security schemes should be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy