Best Buy · API Governance Rules

Best Buy API Rules

Spectral linting rules defining API design standards and conventions for Best Buy.

38 Rules error 15 warn 17 info 6
View Rules File View on GitHub

Rule Categories

delete error get info no openapi operation parameter path paths query response schema security servers

Rules

error
info-title-required
API info must have a title.
$.info
warn
info-title-prefix
API title should begin with "Best Buy".
$.info.title
error
info-description-required
API info must have a description.
$.info
error
info-version-required
API info must have a version.
$.info
error
openapi-version-3
All specs must use OpenAPI 3.0.x.
$
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-bestbuy-domain
Server URLs should use the api.bestbuy.com domain.
$.servers[*].url
warn
paths-kebab-case
Path segments should use kebab-case (lowercase with hyphens).
$.paths[*]~
error
paths-no-trailing-slash
Paths must not have a trailing slash.
$.paths[*]~
error
operation-summary-required
All operations must have a summary.
$.paths[*][get,post,put,patch,delete,options,head]
warn
operation-summary-title-case
Operation summaries should start with "Best Buy" and use Title Case.
$.paths[*][get,post,put,patch,delete].summary
error
operation-description-required
All operations must have a description.
$.paths[*][get,post,put,patch,delete,options,head]
error
operation-id-required
All operations must have an operationId.
$.paths[*][get,post,put,patch,delete,options,head]
warn
operation-id-camel-case
operationId should use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete,options,head]
warn
parameter-description-required
All parameters must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
info
parameter-api-key-query
Best Buy API uses apiKey as a query parameter for authentication.
$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'apiKey')]
info
parameter-naming-camel-case
Parameter names should use camelCase.
$.paths[*][get,post,put,patch,delete].parameters[*].name
error
response-success-required
Operations must define at least one 2xx success response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-unauthorized
Operations requiring authentication should define a 401 response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
response-json-content
Success responses should return application/json content.
$.paths[*][get,post,put,patch,delete].responses['200','201'].content
warn
schema-description-required
Top-level schemas should have a description.
$.components.schemas[*]
info
schema-properties-camel-case
Schema property names should use camelCase.
$.components.schemas[*].properties[*]~
warn
schema-type-required
Schema definitions should have an explicit type.
$.components.schemas[*]
error
security-scheme-defined
Security schemes must be defined in components.
$.components.securitySchemes
warn
security-scheme-description
Security schemes should have a description.
$.components.securitySchemes[*]
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body.
$.paths[*].delete
info
operation-examples-encouraged
Operations should include examples for better developer experience.
$.paths[*][get,post,put,patch,delete].responses[*].content[*]
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
info
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas
warn
operation-documents-401
Operations should document a 401 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
# best-buy — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 3/3 servers on bestbuy.com
#   - path-params-casing: snake @ 75% (n=4)
#   - query-params-casing: snake @ 57% (n=30)
#   - operationid-casing: camel @ 100% (n=8)
#   - schema-names-casing: pascal @ 100% (n=11)
#   - schema-properties-casing: snake @ 62% (n=80)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ErrorResponse
#   - operation-documents-401: 100% adherence
#   - pagination params observed: ['page', 'pageSize']
#   - merge: kept 32 existing, added 6 measured, upgraded 0
#   - added: path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined, operation-documents-401
extends:
  - spectral:oas
rules:
  info-title-required:
    description: API info must have a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-prefix:
    description: API title should begin with "Best Buy".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Best Buy
  info-description-required:
    description: API info must have a description.
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: API info must have a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: All specs must use OpenAPI 3.0.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.0\.
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-bestbuy-domain:
    description: Server URLs should use the api.bestbuy.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: bestbuy\.com
  paths-kebab-case:
    description: Path segments should 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 have a trailing slash.
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  operation-summary-required:
    description: All operations must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: summary
      function: truthy
  operation-summary-title-case:
    description: Operation summaries should start with "Best Buy" and use Title Case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^Best Buy [A-Z]
  operation-description-required:
    description: All operations must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: description
      function: truthy
  operation-id-required:
    description: All operations must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: operationId
      function: truthy
  operation-id-camel-case:
    description: operationId should 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: All operations must have at least one tag.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: All parameters must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-api-key-query:
    description: Best Buy API uses apiKey as a query parameter for authentication.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'apiKey')]
    then:
      field: in
      function: enumeration
      functionOptions:
        values:
        - query
  parameter-naming-camel-case:
    description: Parameter names should use camelCase.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  response-success-required:
    description: Operations must define at least one 2xx success response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '204'
  response-401-unauthorized:
    description: Operations requiring authentication should define a 401 response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          required:
          - '401'
  response-description-required:
    description: All responses must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-json-content:
    description: Success responses should return application/json content.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses['200','201'].content
    then:
      function: truthy
  schema-description-required:
    description: Top-level schemas should have a description.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-properties-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]*$
  schema-type-required:
    description: Schema definitions should have an explicit type.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  security-scheme-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components.securitySchemes
    then:
      function: truthy
  security-scheme-description:
    description: Security schemes should have a description.
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not have a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  operation-examples-encouraged:
    description: Operations should include examples for better developer experience.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses[*].content[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - example
          - required:
            - examples
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy
  operation-documents-401:
    description: Operations should document a 401 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy