@import finitio/data @import webspicy/shared

Method =

String( s | s =~ /^(GET|POST|POST_FORM|PUT|DELETE|PATCH|PUT|OPTIONS)$/ )

FileUpload =

.Webspicy::Web::Specification::FileUpload <info> {
    path         :  String
    content_type :  String
    param_name   :? String
}

Specification = .Webspicy::Web::Specification

<info> {
  name: String
  url: String
  services: [Service]
}
<singleservice> {
  name            :? String
  url             :  String
  method          :  Method
  description     :  String
  preconditions   :? [String]|String
  postconditions  :? [String]|String
  errconditions   :? [String]|String
  input_schema    :  Schema
  output_schema   :  Schema
  error_schema    :  Schema
  blackbox        :? String
  default_example :? TestCase
  examples        :? [TestCase]
  counterexamples :? [TestCase]
}

Service =

.Webspicy::Web::Specification::Service <info> {
    method          :  Method
    description     :  String
    preconditions   :? [String]|String
    postconditions  :? [String]|String
    errconditions   :? [String]|String
    input_schema    :  Schema
    output_schema   :  Schema
    error_schema    :  Schema
    blackbox        :? String
    default_example :? TestCase
    examples        :? [TestCase]
    counterexamples :? [TestCase]
}

TestCase =

.Webspicy::Web::Specification::TestCase <info> {
    description      :? String
    dress_params     :? Boolean
    params           :? Params
    headers          :? .Hash
    body             :? String
    file_upload      :? FileUpload
    seeds            :? String
    requester        :? String
    metadata         :? { ...: .Object }
    expected         :? {
        status       :? StatusRange
        content_type :? String|Nil
        error        :? String
        headers      :? .Hash
    }
    assert           :? [String]
    tags             :? [Tag]
}

StatusRange = .Webspicy::Support::StatusRange

<int> Integer
<str> String(s | s =~ /^\dxx$/ )