Basetrip · API Governance Rules

Basetrip API Rules

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

22 Rules error 6 warn 15 info 1
View Rules File View on GitHub

Rule Categories

basetrip error no path schema security servers

Rules

error
basetrip-api-key-required
All operations must require X-API-Key header authentication.
$.paths.*.*.security
error
basetrip-operation-id-required
All operations must have an operationId.
$.paths.*.*
warn
basetrip-operation-id-camel-case
Operation IDs must use camelCase.
$.paths.*.*.operationId
error
basetrip-summary-required
All operations must have a summary.
$.paths.*.*
warn
basetrip-summary-title-case
Operation summaries must use Title Case.
$.paths.*.*.summary
error
basetrip-tags-required
All operations must be tagged.
$.paths.*.*
warn
basetrip-description-required
All operations must have a description.
$.paths.*.*
error
basetrip-200-response-required
All GET operations must have a 200 response.
$.paths.*.get.responses
warn
basetrip-401-response-defined
Operations should document 401 Unauthorized responses.
$.paths.*.get.responses
warn
basetrip-404-response-defined
Operations on parameterized paths should document 404 responses.
$.paths[*~/*{id}*].*.responses
warn
basetrip-path-kebab-case
Path segments must use kebab-case.
$.paths[*]~
warn
basetrip-schema-description-required
All schema properties should have descriptions.
$.components.schemas.*.properties.*
warn
basetrip-response-schema-ref
Responses should reference schemas using $ref rather than inline definitions.
$.paths.*.*.responses.*.content.application/json.schema
warn
basetrip-info-contact-required
API info must include contact details.
$.info
error
basetrip-server-url-https
Server URLs must use HTTPS.
$.servers.*.url
warn
servers-expected-domain
Server URLs should be on the thebasetrip.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
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
security-schemes-defined
Security schemes should be defined in components.
$.components
warn
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# basetrip — 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: 1/1 servers on thebasetrip.com
#   - path-params-casing: snake @ 100% (n=8)
#   - operationid-casing: camel @ 100% (n=9)
#   - schema-names-casing: pascal @ 100% (n=13)
#   - schema-properties-casing: snake @ 76% (n=41)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ErrorResponse
#   - operation-documents-404: 89% adherence
#   - merge: kept 15 existing, added 7 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, schema-names-casing, schema-properties-casing, security-schemes-defined, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  basetrip-api-key-required:
    description: All operations must require X-API-Key header authentication.
    message: Operation must include ApiKeyAuth security requirement.
    severity: error
    given: $.paths.*.*.security
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            required:
            - ApiKeyAuth
  basetrip-operation-id-required:
    description: All operations must have an operationId.
    message: Operation is missing operationId.
    severity: error
    given: $.paths.*.*
    then:
      field: operationId
      function: truthy
  basetrip-operation-id-camel-case:
    description: Operation IDs must use camelCase.
    message: '{{value}} must use camelCase.'
    severity: warn
    given: $.paths.*.*.operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]+$
  basetrip-summary-required:
    description: All operations must have a summary.
    message: Operation is missing summary.
    severity: error
    given: $.paths.*.*
    then:
      field: summary
      function: truthy
  basetrip-summary-title-case:
    description: Operation summaries must use Title Case.
    message: Summary must use Title Case.
    severity: warn
    given: $.paths.*.*.summary
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9 ]+$
  basetrip-tags-required:
    description: All operations must be tagged.
    message: Operation must include at least one tag.
    severity: error
    given: $.paths.*.*
    then:
      field: tags
      function: truthy
  basetrip-description-required:
    description: All operations must have a description.
    message: Operation is missing description.
    severity: warn
    given: $.paths.*.*
    then:
      field: description
      function: truthy
  basetrip-200-response-required:
    description: All GET operations must have a 200 response.
    message: GET operation is missing 200 success response.
    severity: error
    given: $.paths.*.get.responses
    then:
      field: '200'
      function: truthy
  basetrip-401-response-defined:
    description: Operations should document 401 Unauthorized responses.
    message: Operation is missing 401 response definition.
    severity: warn
    given: $.paths.*.get.responses
    then:
      field: '401'
      function: truthy
  basetrip-404-response-defined:
    description: Operations on parameterized paths should document 404 responses.
    message: Parameterized path operation is missing 404 response.
    severity: warn
    given: $.paths[*~/*{id}*].*.responses
    then:
      field: '404'
      function: truthy
  basetrip-path-kebab-case:
    description: Path segments must use kebab-case.
    message: Path segment must use kebab-case.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z][a-z0-9-]*(/\{[a-zA-Z]+\})?)+$
  basetrip-schema-description-required:
    description: All schema properties should have descriptions.
    message: Schema property is missing description.
    severity: warn
    given: $.components.schemas.*.properties.*
    then:
      field: description
      function: truthy
  basetrip-response-schema-ref:
    description: Responses should reference schemas using $ref rather than inline definitions.
    message: Response content should use $ref to reference schemas.
    severity: warn
    given: $.paths.*.*.responses.*.content.application/json.schema
    then:
      field: $ref
      function: truthy
  basetrip-info-contact-required:
    description: API info must include contact details.
    message: API info is missing contact information.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  basetrip-server-url-https:
    description: Server URLs must use HTTPS.
    message: Server URL must use HTTPS.
    severity: error
    given: $.servers.*.url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the thebasetrip.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: thebasetrip\.com
  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
  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
  security-schemes-defined:
    description: Security schemes should be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  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
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy