extends:
  - spectral:oas

formats:
  - oas3_1

functionsDir: ./spectral-functions

functions:
  - operationSuccessResponse
  - operationErrorResponse

rules:
  info-contact: error
  info-description: error
  info-license: error
  operation-description: warn
  operation-operationId: error
  operation-operationId-unique: error
  operation-tags: error
  oas3-api-servers: error
  operation-success-response:
    description: Every operation must document a 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options,trace]
    then:
      function: operationSuccessResponse
  operation-error-response:
    description: Every operation must document at least one 4xx, 5xx, or default response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options,trace]
    then:
      function: operationErrorResponse
  operation-response-content:
    description: Non-empty response bodies must declare content and a schema.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[?(@property.match(/^(2|4|5|default)/))].content[*]
    then:
      field: schema
      function: truthy
  no-http-server:
    description: Published API server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://"
