Visteon · API Governance Rules

Visteon API Rules

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

10 Rules error 3 warn 5
View Rules File View on GitHub

Rule Categories

visteon

Rules

error
visteon-operation-summary-required
$.paths[*][*]
warn
visteon-summary-title-case
$.paths[*][*].summary
warn
visteon-operationid-camelcase
$.paths[*][*].operationId
warn
visteon-operation-tags
$.paths[*][*]
error
visteon-get-200-response
$.paths[*].get.responses
warn
visteon-post-201-response
$.paths[*].post.responses
hint
visteon-delete-204-response
$.paths[*].delete.responses
warn
visteon-path-params-described
$.paths[*][*].parameters[?(@.in=='path')]
hint
visteon-schema-descriptions
$.components.schemas[*]
error
visteon-put-has-body
$.paths[*].put

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:
  # All operations must have a summary
  visteon-operation-summary-required:
    message: "All Visteon Phoenix API operations must have a summary"
    severity: error
    given: "$.paths[*][*]"
    then:
      field: summary
      function: truthy

  # Summaries must use Title Case
  visteon-summary-title-case:
    message: "Operation summaries must use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]+$"

  # Operation IDs must use camelCase
  visteon-operationid-camelcase:
    message: "Operation IDs must use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  # All operations must be tagged
  visteon-operation-tags:
    message: "All operations must have at least one tag"
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  # GET responses must return 200
  visteon-get-200-response:
    message: "GET operations must return a 200 response"
    severity: error
    given: "$.paths[*].get.responses"
    then:
      field: "200"
      function: truthy

  # POST create operations return 201
  visteon-post-201-response:
    message: "POST create operations should return 201"
    severity: warn
    given: "$.paths[*].post.responses"
    then:
      field: "201"
      function: truthy

  # DELETE operations return 204
  visteon-delete-204-response:
    message: "DELETE operations should return 204"
    severity: hint
    given: "$.paths[*].delete.responses"
    then:
      field: "204"
      function: truthy

  # Path parameters must be described
  visteon-path-params-described:
    message: "All path parameters must have a description"
    severity: warn
    given: "$.paths[*][*].parameters[?(@.in=='path')]"
    then:
      field: description
      function: truthy

  # Schemas must have descriptions
  visteon-schema-descriptions:
    message: "All component schemas must have descriptions"
    severity: hint
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  # PUT operations must have request bodies
  visteon-put-has-body:
    message: "PUT operations must include a requestBody"
    severity: error
    given: "$.paths[*].put"
    then:
      field: requestBody
      function: truthy