Veryfi · API Governance Rules

Veryfi API Rules

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

10 Rules error 2 warn 7 info 1
View Rules File View on GitHub

Rule Categories

veryfi

Rules

warn
veryfi-operation-ids-camel-case
Operation IDs must use camelCase as per Veryfi API conventions
$.paths[*][get,post,put,patch,delete].operationId
warn
veryfi-paths-must-use-partner-prefix
All paths must be under /partner/ namespace
$.paths[*]~
error
veryfi-require-client-id-security
All operations must declare clientId security
$.paths[*][get,post,put,patch,delete]
warn
veryfi-document-responses-must-be-201
Document creation endpoints must return 201 Created
$.paths[*].post.responses
warn
veryfi-require-operation-description
All operations must have a description
$.paths[*][get,post,put,patch,delete]
warn
veryfi-require-operation-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
veryfi-error-responses-must-reference-schema
Error responses must include a schema
$.paths[*][get,post,put,patch,delete].responses['4*','5*'].content['application/json']
info
veryfi-require-api-contact
API info must include contact information
$.info
warn
veryfi-document-id-must-be-integer
Document IDs in paths must be integers
$.paths[*][get,delete].parameters[?(@.name == 'documentId')].schema
error
veryfi-post-requests-must-have-body
POST operations must have a request body defined
$.paths[*].post

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  veryfi-operation-ids-camel-case:
    description: Operation IDs must use camelCase as per Veryfi API conventions
    message: "Operation ID '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  veryfi-paths-must-use-partner-prefix:
    description: All paths must be under /partner/ namespace
    message: "Path '{{path}}' must be under /partner/ namespace"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/partner/"

  veryfi-require-client-id-security:
    description: All operations must declare clientId security
    message: "Operation must require CLIENT-ID authentication"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            security:
              type: array

  veryfi-document-responses-must-be-201:
    description: Document creation endpoints must return 201 Created
    message: "POST document operations must return 201 Created"
    severity: warn
    given: "$.paths[*].post.responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - '201'

  veryfi-require-operation-description:
    description: All operations must have a description
    message: "Operation must include a description"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  veryfi-require-operation-tags:
    description: All operations must have at least one tag
    message: "Operations must have at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: length
      functionOptions:
        min: 1

  veryfi-error-responses-must-reference-schema:
    description: Error responses must include a schema
    message: "Error responses must include a content schema"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses['4*','5*'].content['application/json']"
    then:
      field: schema
      function: truthy

  veryfi-require-api-contact:
    description: API info must include contact information
    message: "API info should include contact information"
    severity: info
    given: "$.info"
    then:
      field: contact
      function: truthy

  veryfi-document-id-must-be-integer:
    description: Document IDs in paths must be integers
    message: "Document ID path parameters must be of type integer"
    severity: warn
    given: "$.paths[*][get,delete].parameters[?(@.name == 'documentId')].schema"
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - integer

  veryfi-post-requests-must-have-body:
    description: POST operations must have a request body defined
    message: "POST operation must define a requestBody"
    severity: error
    given: "$.paths[*].post"
    then:
      field: requestBody
      function: truthy