Trellix Web Gateway · API Governance Rules

Trellix Web Gateway API Rules

Spectral linting rules defining API design standards and conventions for Trellix Web Gateway.

19 Rules error 3 warn 12 info 4
View Rules File View on GitHub

Rule Categories

no operation path query schema servers twg

Rules

warn
twg-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
twg-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
twg-security-defined
All non-login operations must define security requirements
$.paths[?(!@path.match('/login$'))][get,post,put,patch,delete]
error
twg-response-200-get
All GET operations must define a 200 response
$.paths[*].get
warn
twg-response-401-defined
Authenticated operations should define a 401 response
$.paths[*][get,post,put,delete]
warn
twg-tag-defined
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
twg-server-variables
Server URLs with variables must define those variables
$.servers[*].variables[*]
info
twg-cookie-auth
Web Gateway uses session cookie authentication via JSESSIONID
$.components.securitySchemes.cookieAuth
warn
twg-path-kebab-case
API paths should use lowercase letters and hyphens
$.paths[*]~
warn
twg-delete-response
DELETE operations should return 200 or 204
$.paths[*].delete
warn
twg-post-request-body
POST operations that create resources should define a request body
$.paths[*].post
info
twg-xml-content-type
Configuration endpoints use XML content type
$.paths['/configuration'].get.responses.200.content
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
path-params-casing
Path parameters should be camelCase (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
info
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
operation-documents-401
Operations should document a 401 response (documented on 98% 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 ↑
# trellix-web-gateway — 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: camel @ 100% (n=27)
#   - query-params-casing: snake @ 56% (n=36)
#   - operationid-casing: camel @ 97% (n=63)
#   - schema-names-casing: pascal @ 100% (n=35)
#   - schema-properties-casing: snake @ 60% (n=200)
#   - security: global (root) — NOT emitting operation-security-required
#   - operation-documents-401: 98% adherence
#   - pagination params observed: ['limit', 'offset']
#   - merge: kept 12 existing, added 7 measured, upgraded 0
#   - added: servers-https-only, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, operation-documents-401, no-empty-descriptions
extends:
  - spectral:oas
rules:
  twg-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]*$
  twg-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 /()+&-]*$
  twg-security-defined:
    description: All non-login operations must define security requirements
    message: Operation should define security requirements
    severity: error
    given: $.paths[?(!@path.match('/login$'))][get,post,put,patch,delete]
    then:
      field: security
      function: defined
  twg-response-200-get:
    description: All GET operations must define a 200 response
    message: GET operation must define a 200 response
    severity: error
    given: $.paths[*].get
    then:
      field: responses.200
      function: defined
  twg-response-401-defined:
    description: Authenticated operations should define a 401 response
    message: Authenticated operation should define 401 Unauthorized
    severity: warn
    given: $.paths[*][get,post,put,delete]
    then:
      field: responses.401
      function: defined
  twg-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
  twg-server-variables:
    description: Server URLs with variables must define those variables
    message: Server URL variable must have a default value
    severity: warn
    given: $.servers[*].variables[*]
    then:
      field: default
      function: defined
  twg-cookie-auth:
    description: Web Gateway uses session cookie authentication via JSESSIONID
    message: Security scheme must be cookieAuth using JSESSIONID cookie
    severity: info
    given: $.components.securitySchemes.cookieAuth
    then:
      function: defined
  twg-path-kebab-case:
    description: API paths should use lowercase letters and hyphens
    message: Path segment should be lowercase
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z][a-z0-9-]*(/[a-z][a-z0-9-]*|/\{[a-zA-Z][a-zA-Z0-9]*\})*)+$
  twg-delete-response:
    description: DELETE operations should return 200 or 204
    message: DELETE should define a 200 or 204 success response
    severity: warn
    given: $.paths[*].delete
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            responses:
              type: object
  twg-post-request-body:
    description: POST operations that create resources should define a request body
    message: POST operation should define a requestBody
    severity: warn
    given: $.paths[*].post
    then:
      field: requestBody
      function: defined
  twg-xml-content-type:
    description: Configuration endpoints use XML content type
    message: Configuration endpoints should support application/xml
    severity: info
    given: $.paths['/configuration'].get.responses.200.content
    then:
      function: defined
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  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: info
    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
  operation-documents-401:
    description: Operations should document a 401 response (documented on 98% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy