-
Notifications
You must be signed in to change notification settings - Fork 0
Request File
Request File
is a UTF-8 encoded text file which describes your HTTP request intuitively, one request file should only represent one request.
Its format looks like below:
{HTTP Method} {path}
> {header key 1}: {header value 1}
> {header key 2}: {header value 2}
{body}
Note that the {path}
in the Request File
is based on the Host
of swaggerBaseURL
the confiuration file.
For example: If the
swaggerBaseURL
ishttp://www.example.com:8080/api/api-docs
and the{path}
in theRequest File
is/foo/bar
, the actual path of the request would behttp://www.example.com:8080/foo/bar
Besides, a Request File
can also accept arguments, you can analogize it as a function in bash shell, its name is the function name and the argument is the arguments of the function.
Showing examples is much more clear and easier to explaining the detail syntax of the Request File.
A GET request with
Accept
header and without body and goes to/shopping-cart
GET /shopping-cart
> Accept: application/json
A POST request with
Accept
andContent-Type
headers, as well as a JSON body, and goes to path/shopping-cart
POST /shopping-cart
> Accept: application/json
> Content-Type: application/json
{ "items": [
{
"url": "/shopping-cart/1",
"product":"2ZY48XPZ",
"quantity": 1,
"name": "New socks",
"price": 1.25
} ]
}
A PUT Request File accepts 2 arguments, one used in
If-Match
header and the other one used in path and body.
PUT /shopping-cart/{{{1}}}
> Accept: application/json
> Content-Type: application/json
> If-Match: {{{0}}}
{
"count":1,
"items":[
{
"url":"/shopping-cart/{{{1}}}",
"product":"2ZY48XPZ",
"quantity":1,
"name":"New socks",
"price":1.25
}
]
}
The number between {{{
and }}}
is the index of given arguments, starting from zero.
For instance, if the arguments are
12345678
andabc-def
, the actual request would be:
PUT /shopping-cart/abc-def > Accept: application/json > Content-Type: application/json > If-Match: 12345678 { "count":1, "items":[ { "url":"/shopping-cart/abc-def", "product":"2ZY48XPZ", "quantity":1, "name":"New socks", "price":1.25 } ] }
You can write any GET
,POST
,DELETE
,PATCH
,PUT
requests like above samples.