BetSolutions · API Governance Rules

BetSolutions API Rules

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

30 Rules error 15 warn 13 info 2
View Rules File View on GitHub

Rule Categories

get hash info no openapi operation parameter paths post request 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 "BetSolutions".
$.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-betsolutions-domain
Server URLs should use a betsolutions.com domain.
$.servers[*].url
warn
paths-kebab-case
Path segments should use kebab-case.
$.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-prefix
Operation summaries should start with "BetSolutions".
$.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
post-request-body-required
POST operations should have a request body.
$.paths[*].post
warn
request-body-json
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
warn
parameter-description-required
All parameters must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
info
hash-parameter-required
BetSolutions API requires SHA-256 hash parameter for authentication.
$.paths[*][post].requestBody.content['application/json'].schema.properties
error
response-success-required
Operations must define at least one 2xx success 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'].content
warn
response-401-defined
Operations should define a 401 unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
warn
schema-description-required
Top-level schemas should have a description.
$.components.schemas[*]
warn
schema-type-required
Schema definitions should have an explicit type.
$.components.schemas[*]
info
schema-success-flag
BetSolutions response schemas should include a success boolean field.
$.components.schemas[*].properties
error
security-scheme-defined
Security schemes must be defined in components.
$.components.securitySchemes
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  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 "BetSolutions".
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^BetSolutions"

  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
  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
  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-betsolutions-domain:
    description: Server URLs should use a betsolutions.com domain.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "betsolutions\\.com"

  # PATHS - NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments should use kebab-case.
    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: "/$"

  # OPERATIONS
  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-prefix:
    description: Operation summaries should start with "BetSolutions".
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^BetSolutions [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

  # REQUEST BODIES
  post-request-body-required:
    description: POST operations should have a request body.
    severity: warn
    given: "$.paths[*].post"
    then:
      field: requestBody
      function: truthy

  request-body-json:
    description: Request bodies should use application/json content type.
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      function: schema
      functionOptions:
        schema:
          required: ['application/json']

  # PARAMETERS
  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

  hash-parameter-required:
    description: BetSolutions API requires SHA-256 hash parameter for authentication.
    severity: info
    given: "$.paths[*][post].requestBody.content['application/json'].schema.properties"
    then:
      function: schema
      functionOptions:
        schema:
          required: ['hash']

  # RESPONSES
  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']

  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'].content"
    then:
      function: truthy

  response-401-defined:
    description: Operations should define a 401 unauthorized response.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          required: ['401']

  # SCHEMAS
  schema-description-required:
    description: Top-level schemas should have a description.
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  schema-type-required:
    description: Schema definitions should have an explicit type.
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: type
      function: truthy

  schema-success-flag:
    description: BetSolutions response schemas should include a success boolean field.
    severity: info
    given: "$.components.schemas[*].properties"
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
            - required: ['success']
            - not:
                required: []

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

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

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