Arlula · API Governance Rules

Arlula API Rules

Spectral linting rules defining API design standards and conventions for Arlula.

30 Rules error 14 warn 14 info 2
View Rules File View on GitHub

Rule Categories

arlula

Rules

error
arlula-info-title
API must have a title.
$.info
warn
arlula-info-description
API must have a description.
$.info
error
arlula-info-version
API must have a version.
$.info
warn
arlula-info-contact
API should have contact information.
$.info
error
arlula-openapi-version
Must use OpenAPI 3.0.x.
$
error
arlula-servers-present
API must have servers defined.
$
error
arlula-servers-https
All server URLs must use HTTPS.
$.servers[*]
error
arlula-paths-present
API must have paths defined.
$
warn
arlula-path-kebab-case
Path segments should use kebab-case or camelCase consistently.
$.paths[*]~
error
arlula-operation-summary
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete,options,head]
warn
arlula-operation-description
Every operation should have a description.
$.paths[*][get,post,put,patch,delete,options,head]
error
arlula-operation-tags
Every operation must have tags.
$.paths[*][get,post,put,patch,delete,options,head]
error
arlula-operation-id
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete,options,head]
warn
arlula-parameter-description
Parameters should have descriptions.
$.paths[*][get,post,put,patch,delete][parameters][*]
error
arlula-parameter-schema
Parameters must have a schema.
$.paths[*][get,post,put,patch,delete][parameters][*]
error
arlula-request-body-content
Request bodies must have content defined.
$.paths[*][post,put,patch].requestBody
warn
arlula-request-body-json
POST/PUT/PATCH operations should accept application/json.
$.paths[*][post,put,patch].requestBody.content
warn
arlula-response-200
GET operations should define a 200 response.
$.paths[*].get.responses
error
arlula-response-description
Responses must have descriptions.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
arlula-response-401
Operations should document 401 Unauthorized responses.
$.paths[*][get,post,put,patch,delete].responses
warn
arlula-response-500
Operations should document 500 error responses.
$.paths[*][get,post,put,patch,delete].responses
warn
arlula-schema-title
Schemas in components should have titles.
$.components.schemas[*]
warn
arlula-schema-description
Schemas should have descriptions.
$.components.schemas[*]
warn
arlula-property-description
Schema properties should have descriptions.
$.components.schemas[*].properties[*]
info
arlula-property-example
Schema properties should have examples.
$.components.schemas[*].properties[*]
error
arlula-security-defined
API must define security schemes.
$.components
error
arlula-security-basic-auth
Arlula API uses HTTP Basic authentication.
$.components.securitySchemes.BasicAuth
warn
arlula-archive-search-post
Archive search must use POST method.
$.paths['/api/archive/search']
warn
arlula-tasking-search-post
Tasking search must use POST method.
$.paths['/api/tasking/search']
info
arlula-resource-data-binary
Resource data download should support binary responses.
$.paths['/api/resource/{resource}/data'].get.responses['200'].content

Spectral Ruleset

Raw ↑
rules:
  # Info Rules
  arlula-info-title:
    description: API must have a title.
    message: "Info object must have a non-empty title."
    severity: error
    given: "$.info"
    then:
      field: title
      function: truthy

  arlula-info-description:
    description: API must have a description.
    message: "Info object must have a non-empty description."
    severity: warn
    given: "$.info"
    then:
      field: description
      function: truthy

  arlula-info-version:
    description: API must have a version.
    message: "Info object must have a version."
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  arlula-info-contact:
    description: API should have contact information.
    message: "Info object should include contact details."
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  # OpenAPI Version
  arlula-openapi-version:
    description: Must use OpenAPI 3.0.x.
    message: "OpenAPI version must be 3.0.x."
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\.0\\."

  # Servers Rules
  arlula-servers-present:
    description: API must have servers defined.
    message: "Servers array must be present and non-empty."
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  arlula-servers-https:
    description: All server URLs must use HTTPS.
    message: "Server URL must use HTTPS."
    severity: error
    given: "$.servers[*]"
    then:
      field: url
      function: pattern
      functionOptions:
        match: "^https://"

  # Paths Rules
  arlula-paths-present:
    description: API must have paths defined.
    message: "Paths object must be present and non-empty."
    severity: error
    given: "$"
    then:
      field: paths
      function: truthy

  arlula-path-kebab-case:
    description: Path segments should use kebab-case or camelCase consistently.
    message: "Path should follow consistent casing conventions."
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/[a-zA-Z0-9/{}_-]*$"

  # Operations Rules
  arlula-operation-summary:
    description: Every operation must have a summary.
    message: "Operation must have a summary."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,options,head]"
    then:
      field: summary
      function: truthy

  arlula-operation-description:
    description: Every operation should have a description.
    message: "Operation should have a description."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete,options,head]"
    then:
      field: description
      function: truthy

  arlula-operation-tags:
    description: Every operation must have tags.
    message: "Operation must have at least one tag."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,options,head]"
    then:
      field: tags
      function: truthy

  arlula-operation-id:
    description: Every operation must have an operationId.
    message: "Operation must have an operationId."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,options,head]"
    then:
      field: operationId
      function: truthy

  # Parameters Rules
  arlula-parameter-description:
    description: Parameters should have descriptions.
    message: "Parameter should have a description."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete][parameters][*]"
    then:
      field: description
      function: truthy

  arlula-parameter-schema:
    description: Parameters must have a schema.
    message: "Parameter must have a schema."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete][parameters][*]"
    then:
      field: schema
      function: truthy

  # Request Body Rules
  arlula-request-body-content:
    description: Request bodies must have content defined.
    message: "Request body must have content."
    severity: error
    given: "$.paths[*][post,put,patch].requestBody"
    then:
      field: content
      function: truthy

  arlula-request-body-json:
    description: POST/PUT/PATCH operations should accept application/json.
    message: "Request body should support application/json content type."
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      function: truthy

  # Response Rules
  arlula-response-200:
    description: GET operations should define a 200 response.
    message: "GET operation should have a 200 response."
    severity: warn
    given: "$.paths[*].get.responses"
    then:
      field: "200"
      function: truthy

  arlula-response-description:
    description: Responses must have descriptions.
    message: "Response must have a description."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses[*]"
    then:
      field: description
      function: truthy

  arlula-response-401:
    description: Operations should document 401 Unauthorized responses.
    message: "Operation should define a 401 response."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: truthy

  arlula-response-500:
    description: Operations should document 500 error responses.
    message: "Operation should define a 500 response."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "500"
      function: truthy

  # Schema Rules
  arlula-schema-title:
    description: Schemas in components should have titles.
    message: "Schema must have a title."
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: title
      function: truthy

  arlula-schema-description:
    description: Schemas should have descriptions.
    message: "Schema should have a description."
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  arlula-property-description:
    description: Schema properties should have descriptions.
    message: "Schema property should have a description."
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  arlula-property-example:
    description: Schema properties should have examples.
    message: "Schema property should have an example value."
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: example
      function: truthy

  # Security Rules
  arlula-security-defined:
    description: API must define security schemes.
    message: "Security schemes must be defined in components."
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  arlula-security-basic-auth:
    description: Arlula API uses HTTP Basic authentication.
    message: "BasicAuth security scheme must use http type with basic scheme."
    severity: error
    given: "$.components.securitySchemes.BasicAuth"
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - http

  # Satellite Imagery Specific Rules
  arlula-archive-search-post:
    description: Archive search must use POST method.
    message: "Archive search endpoint must use POST."
    severity: warn
    given: "$.paths['/api/archive/search']"
    then:
      field: post
      function: truthy

  arlula-tasking-search-post:
    description: Tasking search must use POST method.
    message: "Tasking search endpoint must use POST."
    severity: warn
    given: "$.paths['/api/tasking/search']"
    then:
      field: post
      function: truthy

  arlula-resource-data-binary:
    description: Resource data download should support binary responses.
    message: "Resource data endpoint should return binary content type."
    severity: info
    given: "$.paths['/api/resource/{resource}/data'].get.responses['200'].content"
    then:
      function: truthy