albertsons · API Governance Rules

albertsons API Rules

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

35 Rules error 16 warn 14 info 5
View Rules File View on GitHub

Rule Categories

delete examples get info no openapi operation parameter paths request response schema security servers tags

Rules

error
info-title-required
Info title must be defined and start with "Albertsons".
$.info.title
error
info-description-required
Info description must be defined with meaningful content.
$.info.description
error
info-version-required
API version must be specified.
$.info.version
warn
info-contact-required
Contact information should be provided.
$.info.contact
error
openapi-version-3
All specs must use OpenAPI 3.x.
$.openapi
error
servers-required
At least one server must be defined.
$.servers
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
paths-kebab-case
Path segments must use kebab-case (lowercase with hyphens).
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths[*]~
info
paths-plural-resource-nouns
Resource path segments should use plural nouns.
$.paths[*]~
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete].summary
warn
operation-summary-albertsons-prefix
Operation summaries must start with "Albertsons".
$.paths[*][get,post,put,patch,delete].summary
error
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete].description
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete].operationId
warn
operation-operationid-camel-case
operationId must use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete].tags
warn
tags-global-defined
Global tags array should be defined.
$.tags
warn
tags-description-required
All global tags must have descriptions.
$.tags[*].description
error
parameter-description-required
All parameters must have descriptions.
$.paths[*][get,post,put,patch,delete].parameters[*].description
info
parameter-snake-case
Query and path parameter names should use camelCase or snake_case.
$.paths[*][get,post,put,patch,delete].parameters[*].name
warn
request-body-content-json
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
info
request-body-description
Request body content should have a schema with description.
$.paths[*][post,put,patch].requestBody
error
response-success-required
Every operation must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-required
Secured endpoints should define a 401 response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have descriptions.
$.paths[*][get,post,put,patch,delete].responses[*].description
warn
schema-description-required
Top-level schemas must have descriptions.
$.components.schemas[*].description
warn
schema-type-required
All schemas must define a type.
$.components.schemas[*].type
info
schema-property-camel-case
Schema property names should use camelCase.
$.components.schemas[*].properties[*]~
error
security-schemes-defined
Security schemes must be defined in components.
$.components.securitySchemes
warn
security-bearer-auth
Bearer authentication scheme should be defined.
$.components.securitySchemes.bearerAuth
warn
security-operation-defined
Each operation should define security requirements.
$.paths[*][get,post,put,patch,delete].security
error
get-no-request-body
GET operations must not have request bodies.
$.paths[*].get.requestBody
warn
delete-no-request-body
DELETE operations should not have request bodies.
$.paths[*].delete.requestBody
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Schema properties should include example values.
$.components.schemas[*].properties[*]

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-required:
    description: Info title must be defined and start with "Albertsons".
    severity: error
    given: "$.info.title"
    then:
      function: truthy

  info-description-required:
    description: Info description must be defined with meaningful content.
    severity: error
    given: "$.info.description"
    then:
      function: truthy

  info-version-required:
    description: API version must be specified.
    severity: error
    given: "$.info.version"
    then:
      function: truthy

  info-contact-required:
    description: Contact information should be provided.
    severity: warn
    given: "$.info.contact"
    then:
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: All specs must use OpenAPI 3.x.
    severity: error
    given: "$.openapi"
    then:
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-required:
    description: At least one server must be defined.
    severity: error
    given: "$.servers"
    then:
      function: truthy

  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments must use kebab-case (lowercase with hyphens).
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9-{}]+)+$"

  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  paths-plural-resource-nouns:
    description: Resource path segments should use plural nouns.
    severity: info
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9-{}]*s[a-z0-9-{}]*|/[a-z0-9-{}]*)+$"

  # OPERATIONS
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: truthy

  operation-summary-albertsons-prefix:
    description: Operation summaries must start with "Albertsons".
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Albertsons"

  operation-description-required:
    description: Every operation must have a description.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].description"
    then:
      function: truthy

  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: truthy

  operation-operationid-camel-case:
    description: operationId must use camelCase.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

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

  # TAGS
  tags-global-defined:
    description: Global tags array should be defined.
    severity: warn
    given: "$.tags"
    then:
      function: truthy

  tags-description-required:
    description: All global tags must have descriptions.
    severity: warn
    given: "$.tags[*].description"
    then:
      function: truthy

  # PARAMETERS
  parameter-description-required:
    description: All parameters must have descriptions.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].parameters[*].description"
    then:
      function: truthy

  parameter-snake-case:
    description: Query and path parameter names should use camelCase or snake_case.
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].parameters[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9_]*$"

  # REQUEST BODIES
  request-body-content-json:
    description: Request bodies should use application/json content type.
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      function: truthy

  request-body-description:
    description: Request body content should have a schema with description.
    severity: info
    given: "$.paths[*][post,put,patch].requestBody"
    then:
      function: truthy

  # RESPONSES
  response-success-required:
    description: Every operation must define at least one 2xx response.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  response-401-required:
    description: Secured endpoints should define a 401 response.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: truthy

  response-description-required:
    description: All responses must have descriptions.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses[*].description"
    then:
      function: truthy

  # SCHEMAS — PROPERTY NAMING
  schema-description-required:
    description: Top-level schemas must have descriptions.
    severity: warn
    given: "$.components.schemas[*].description"
    then:
      function: truthy

  schema-type-required:
    description: All schemas must define a type.
    severity: warn
    given: "$.components.schemas[*].type"
    then:
      function: truthy

  schema-property-camel-case:
    description: Schema property names should use camelCase.
    severity: info
    given: "$.components.schemas[*].properties[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

  security-bearer-auth:
    description: Bearer authentication scheme should be defined.
    severity: warn
    given: "$.components.securitySchemes.bearerAuth"
    then:
      function: truthy

  security-operation-defined:
    description: Each operation should define security requirements.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].security"
    then:
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have request bodies.
    severity: error
    given: "$.paths[*].get.requestBody"
    then:
      function: falsy

  delete-no-request-body:
    description: DELETE operations should not have request bodies.
    severity: warn
    given: "$.paths[*].delete.requestBody"
    then:
      function: falsy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: error
    given: "$..description"
    then:
      function: pattern
      functionOptions:
        match: ".+"

  examples-encouraged:
    description: Schema properties should include example values.
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      function: truthy