Spring Boot · API Governance Rules

Spring Boot API Rules

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

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

Rule Categories

spring

Rules

warn
spring-boot-actuator-operation-id-prefix
Actuator operation IDs should be descriptive and use camelCase
$.paths[*][get,post,put,delete,patch].operationId
warn
spring-boot-actuator-summary-title-case
All operation summaries must use Title Case
$.paths[*][get,post,put,delete,patch].summary
error
spring-boot-actuator-tags-defined
All operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
warn
spring-boot-actuator-tags-title-case
All tags must use Title Case
$.paths[*][get,post,put,delete,patch].tags[*]
error
spring-boot-actuator-response-200-defined
All GET operations must define a 200 response
$.paths[*].get
warn
spring-boot-actuator-path-lowercase-kebab
Actuator endpoint paths should use lowercase with hyphens
$.paths
error
spring-boot-actuator-no-trailing-slash
Paths must not end with a trailing slash
$.paths
warn
spring-boot-actuator-info-contact-defined
API info must include contact information
$.info
error
spring-boot-actuator-servers-defined
At least one server must be defined
$

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:

  spring-boot-actuator-operation-id-prefix:
    description: Actuator operation IDs should be descriptive and use camelCase
    message: "Operation ID '{{value}}' should be camelCase and descriptive (e.g., getHealth, listMetrics)"
    given: "$.paths[*][get,post,put,delete,patch].operationId"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  spring-boot-actuator-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][^a-z]*([A-Z][^a-z]*)*"

  spring-boot-actuator-tags-defined:
    description: All operations must have at least one tag
    message: "Operation '{{path}}' is missing tags"
    given: "$.paths[*][get,post,put,delete,patch]"
    severity: error
    then:
      field: tags
      function: truthy

  spring-boot-actuator-tags-title-case:
    description: All tags must use Title Case
    message: "Tag '{{value}}' should be in Title Case (e.g., 'Health', 'Metrics', 'Environment')"
    given: "$.paths[*][get,post,put,delete,patch].tags[*]"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z ]+$"

  spring-boot-actuator-response-200-defined:
    description: All GET operations must define a 200 response
    message: "GET operation at '{{path}}' must define a 200 response"
    given: "$.paths[*].get"
    severity: error
    then:
      field: responses.200
      function: truthy

  spring-boot-actuator-path-lowercase-kebab:
    description: Actuator endpoint paths should use lowercase with hyphens
    message: "Path '{{path}}' should use lowercase kebab-case"
    given: "$.paths"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^\\/[a-z0-9\\-\\/\\{\\}]*$"

  spring-boot-actuator-no-trailing-slash:
    description: Paths must not end with a trailing slash
    message: "Path '{{path}}' must not end with a trailing slash"
    given: "$.paths"
    severity: error
    then:
      function: pattern
      functionOptions:
        notMatch: ".*\\/$"

  spring-boot-actuator-info-contact-defined:
    description: API info must include contact information
    message: "API info must include a contact block with name and url"
    given: "$.info"
    severity: warn
    then:
      field: contact
      function: truthy

  spring-boot-actuator-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