Spring Cloud Gateway · API Governance Rules

Spring Cloud Gateway API Rules

Spectral linting rules defining API design standards and conventions for Spring Cloud Gateway.

9 Rules error 4 warn 5
View Rules File View on GitHub

Rule Categories

spring

Rules

warn
spring-cloud-gateway-operation-id-camel-case
Operation IDs must be camelCase
$.paths[*][get,post,put,delete,patch].operationId
warn
spring-cloud-gateway-summary-title-case
All operation summaries must use Title Case
$.paths[*][get,post,put,delete,patch].summary
error
spring-cloud-gateway-tags-required
All operations must declare at least one tag
$.paths[*][get,post,put,delete,patch]
warn
spring-cloud-gateway-tags-title-case
Tags must be Title Case
$.paths[*][get,post,put,delete,patch].tags[*]
error
spring-cloud-gateway-route-id-required
Route definitions must include an id field
$.components.schemas.RouteDefinition
error
spring-cloud-gateway-route-uri-required
Route definitions must include a uri field
$.components.schemas.RouteDefinition
error
spring-cloud-gateway-servers-defined
At least one server must be defined
$
warn
spring-cloud-gateway-path-parameters-described
All path parameters must have a description
$.paths[*][get,post,put,delete,patch].parameters[?(@.in == 'path')]
warn
spring-cloud-gateway-delete-responses-defined
DELETE operations must define response codes
$.paths[*].delete

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:

  spring-cloud-gateway-operation-id-camel-case:
    description: Operation IDs must be camelCase
    message: "Operation ID '{{value}}' must use camelCase"
    given: "$.paths[*][get,post,put,delete,patch].operationId"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  spring-cloud-gateway-summary-title-case:
    description: All operation summaries must use Title Case
    message: "Summary '{{value}}' should use Title Case"
    given: "$.paths[*][get,post,put,delete,patch].summary"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  spring-cloud-gateway-tags-required:
    description: All operations must declare at least one tag
    message: "Operation is missing tags"
    given: "$.paths[*][get,post,put,delete,patch]"
    severity: error
    then:
      field: tags
      function: truthy

  spring-cloud-gateway-tags-title-case:
    description: Tags must be Title Case
    message: "Tag '{{value}}' must use Title Case"
    given: "$.paths[*][get,post,put,delete,patch].tags[*]"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z ]+$"

  spring-cloud-gateway-route-id-required:
    description: Route definitions must include an id field
    message: "Route definition schema must require an 'id' field"
    given: "$.components.schemas.RouteDefinition"
    severity: error
    then:
      field: required
      function: truthy

  spring-cloud-gateway-route-uri-required:
    description: Route definitions must include a uri field
    message: "Route definition schema must require a 'uri' field"
    given: "$.components.schemas.RouteDefinition"
    severity: error
    then:
      field: required
      function: truthy

  spring-cloud-gateway-servers-defined:
    description: At least one server must be defined
    message: "OpenAPI spec must define at least one server"
    given: "$"
    severity: error
    then:
      field: servers
      function: truthy

  spring-cloud-gateway-path-parameters-described:
    description: All path parameters must have a description
    message: "Path parameter '{{value}}' is missing a description"
    given: "$.paths[*][get,post,put,delete,patch].parameters[?(@.in == 'path')]"
    severity: warn
    then:
      field: description
      function: truthy

  spring-cloud-gateway-delete-responses-defined:
    description: DELETE operations must define response codes
    message: "DELETE operation should define both 200 (success) and 404 (not found) responses"
    given: "$.paths[*].delete"
    severity: warn
    then:
      field: responses
      function: truthy