Weave Net · API Governance Rules

Weave Net API Rules

Spectral linting rules defining API design standards and conventions for Weave Net.

22 Rules error 8 warn 8 info 6
View Rules File View on GitHub

Rule Categories

delete get info openapi operation parameter response schema servers

Rules

error
info-title-required
Info must have a title
$.info
warn
info-description-required
Info must have a description
$.info
error
info-version-required
Info must have a version
$.info
info
info-contact-recommended
Info should have contact information
$.info
warn
info-license-required
Info should have license information
$.info
error
openapi-version-3
Must use OpenAPI 3.x
$
error
servers-required
Servers must be defined
$
info
servers-description-required
Server entries should have descriptions
$.servers[*]
error
operation-operationId-required
Every operation must have an operationId
$.paths[*][get,post,put,delete,patch]
warn
operation-operationId-camel-case
OperationIds must use camelCase
$.paths[*][get,post,put,delete,patch].operationId
warn
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,delete,patch]
info
operation-summary-weave-net-prefix
Operation summaries must start with 'Weave Net'
$.paths[*][get,post,put,delete,patch].summary
warn
operation-description-required
Operations should have descriptions
$.paths[*][get,post,put,delete,patch]
warn
operation-tags-required
Operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
warn
parameter-description-required
Parameters should have descriptions
$.paths[*][get,post,put,delete,patch].parameters[*]
error
parameter-schema-required
Parameters must have a schema
$.paths[*][get,post,put,delete,patch].parameters[*]
error
response-success-required
Every operation must have a success response
$.paths[*][get,post,put,delete,patch].responses
warn
response-description-required
Every response must have a description
$.paths[*][get,post,put,delete,patch].responses[*]
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
info
delete-returns-correct-status
DELETE operations should return 204 or 200
$.paths[*].delete.responses
info
schema-properties-described
Schema properties should have descriptions
$.components.schemas[*].properties[*]
info
operation-microcks-extension
Operations should have x-microcks-operation for mock support
$.paths[*][get,post,put,delete,patch]

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-required:
    description: Info must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy

  info-description-required:
    description: Info must have a description
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy

  info-version-required:
    description: Info must have a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy

  info-contact-recommended:
    description: Info should have contact information
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy

  info-license-required:
    description: Info should have license information
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy

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

  # SERVERS
  servers-required:
    description: Servers must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  servers-description-required:
    description: Server entries should have descriptions
    severity: info
    given: $.servers[*]
    then:
      field: description
      function: truthy

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

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

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

  operation-summary-weave-net-prefix:
    description: Operation summaries must start with 'Weave Net'
    severity: info
    given: $.paths[*][get,post,put,delete,patch].summary
    then:
      function: pattern
      functionOptions:
        match: "^Weave Net"

  operation-description-required:
    description: Operations should have descriptions
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: description
      function: truthy

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

  # PARAMETERS
  parameter-description-required:
    description: Parameters should have descriptions
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].parameters[*]
    then:
      field: description
      function: truthy

  parameter-schema-required:
    description: Parameters must have a schema
    severity: error
    given: $.paths[*][get,post,put,delete,patch].parameters[*]
    then:
      field: schema
      function: truthy

  # RESPONSES
  response-success-required:
    description: Every operation must have a success response
    severity: error
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          minProperties: 1

  response-description-required:
    description: Every response must have a description
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].responses[*]
    then:
      field: description
      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

  delete-returns-correct-status:
    description: DELETE operations should return 204 or 200
    severity: info
    given: $.paths[*].delete.responses
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['204']
            - required: ['200']

  # SCHEMAS
  schema-properties-described:
    description: Schema properties should have descriptions
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy

  # MICROCKS EXTENSIONS
  operation-microcks-extension:
    description: Operations should have x-microcks-operation for mock support
    severity: info
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: x-microcks-operation
      function: truthy