Spring Data · API Governance Rules

Spring Data API Rules

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

7 Rules error 1 warn 4 info 2
View Rules File View on GitHub

Rule Categories

spring

Rules

warn
spring-data-hal-content-type
Spring Data REST endpoints should accept/produce application/hal+json
$.paths[*][*].responses[*].content
info
spring-data-pageable-parameters
Collection endpoints should support page, size, and sort query parameters
$.paths[*].get
error
spring-data-rest-operation-ids
All operations must have a unique operationId
$.paths[*][get,post,put,patch,delete]
warn
spring-data-rest-tags
Operations must include at least one tag using Title Case
$.paths[*][get,post,put,patch,delete]
warn
spring-data-no-trailing-slashes
API paths must not have trailing slashes
$.paths
info
spring-data-hateoas-links
Resource schemas should include _links property for HATEOAS compliance
$.components.schemas[*]
warn
spring-data-rest-summaries-title-case
Operation summaries must use Title Case
$.paths[*][*].summary

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  spring-data-hal-content-type:
    description: Spring Data REST endpoints should accept/produce application/hal+json
    message: "{{description}}. Found: {{value}}"
    severity: warn
    given: "$.paths[*][*].responses[*].content"
    then:
      field: "application/hal+json"
      function: truthy

  spring-data-pageable-parameters:
    description: Collection endpoints should support page, size, and sort query parameters
    message: "Collection GET operations should include page, size, and sort parameters"
    severity: info
    given: "$.paths[*].get"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  spring-data-rest-operation-ids:
    description: All operations must have a unique operationId
    message: "Operation is missing operationId"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  spring-data-rest-tags:
    description: Operations must include at least one tag using Title Case
    message: "Operation must have tags"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  spring-data-no-trailing-slashes:
    description: API paths must not have trailing slashes
    message: "Path {{path}} has a trailing slash"
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  spring-data-hateoas-links:
    description: Resource schemas should include _links property for HATEOAS compliance
    message: "Resource schemas should define _links property"
    severity: info
    given: "$.components.schemas[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  spring-data-rest-summaries-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]"