TheSpaceDevs LL2 API · API Governance Rules

TheSpaceDevs LL2 API API Rules

Spectral linting rules defining API design standards and conventions for TheSpaceDevs LL2 API.

9 Rules error 2 warn 3 info 4
View Rules File View on GitHub

Rule Categories

thespacedevs

Rules

warn
thespacedevs-operation-summary-title-case
All operation summaries must use Title Case.
$.paths[*][*].summary
info
thespacedevs-operation-ids-snake-case
LL2 API uses snake_case operationIds in format resource_action.
$.paths[*][*].operationId
warn
thespacedevs-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
thespacedevs-description-required
All operations should have a description.
$.paths[*][get,post,put,patch,delete]
error
thespacedevs-200-response-defined
All GET operations must define a 200 response.
$.paths[*][get].responses
info
thespacedevs-list-has-limit-param
List operations should support a limit query parameter.
$.paths[*~][?(@.get)]
warn
thespacedevs-path-version-prefix
All paths should include the API version prefix /2.3.0/.
$.paths[*]~
info
thespacedevs-path-trailing-slash
LL2 API paths use trailing slashes.
$.paths[*]~
error
thespacedevs-servers-defined
At least one server URL must be defined.
$

Spectral Ruleset

Raw ↑
rules:
  thespacedevs-operation-summary-title-case:
    description: All operation summaries must use Title Case.
    message: "Operation summary '{{value}}' must use Title Case."
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  thespacedevs-operation-ids-snake-case:
    description: LL2 API uses snake_case operationIds in format resource_action.
    message: "OperationId '{{value}}' should use snake_case (resource_action pattern)."
    severity: info
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-z0-9_]*$"

  thespacedevs-tags-required:
    description: All operations must have at least one tag.
    message: "Operation at '{{path}}' must have at least one tag."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  thespacedevs-description-required:
    description: All operations should have a description.
    message: "Operation at '{{path}}' is missing a description."
    severity: info
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

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

  thespacedevs-list-has-limit-param:
    description: List operations should support a limit query parameter.
    message: "List operation at '{{path}}' should support 'limit' parameter."
    severity: info
    given: "$.paths[*~][?(@.get)]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  thespacedevs-path-version-prefix:
    description: All paths should include the API version prefix /2.3.0/.
    message: "Path '{{path}}' should start with the API version prefix /2.3.0/."
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^\\/2\\.3\\.0\\/"

  thespacedevs-path-trailing-slash:
    description: LL2 API paths use trailing slashes.
    message: "Path '{{path}}' should end with a trailing slash per LL2 API convention."
    severity: info
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "\\/$"

  thespacedevs-servers-defined:
    description: At least one server URL must be defined.
    message: "No server URLs defined."
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy