spec: provide custom reason phrase for http error responses and fixes

Co-authored-by: pancho horrillo <pedrofelipe.horrillo@bbva.com>
This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-05-23 13:02:57 +02:00
parent bb991a56c2
commit 39c60e5c93
+37 -48
View File
@@ -149,7 +149,7 @@ Returns JSON data about the current routes.
* **URL**: `/routes` * **URL**: `/routes`
* **Method**: `GET` * **Method**: `GET`
* **Success Response**: * **Success Responses**:
* **Code**: `200 OK`<br /> * **Code**: `200 OK`<br />
**Content**: TODO **Content**: TODO
* **Sample Call**: TODO * **Sample Call**: TODO
@@ -186,12 +186,11 @@ Accepts JSON data that defines a new route to be appended to the current routes.
} }
``` ```
* **Error Responses**: * **Error Responses**:
* **Code**: `400 Bad Request`<br /> * **Code**: `400 Malformed JSON`
* **Code**: `400 Invalid Data Type`
* **Code**: `400 Missing Mandatory Field`<br />
**Header**: `Content-Type: application/json`<br /> **Header**: `Content-Type: application/json`<br />
**Content**: `{ "error": "Malformed JSON." }` **Content**: `{ "mandatory_fields": ["field1", "field2", "and so on"] }`
* **Code**: `400 Bad Request`<br />
**Header**: `Content-Type: application/json`<br />
**Content**: `{ "error": "Mandatory field(s) not provided." }`
* **Sample Call**: TODO * **Sample Call**: TODO
* **Notes**: * **Notes**:
* A successful request will yield a response containing all the effective * A successful request will yield a response containing all the effective
@@ -229,12 +228,12 @@ Accepts JSON data that defines a new route to be appended to the current routes.
} }
``` ```
* **Error Responses**: * **Error Responses**:
* **Code**: `400 Bad Request`<br /> * **Code**: `400 Malformed JSON`
* **Code**: `400 Invalid Data Type`
* **Code**: `400 Missing Mandatory Field`<br />
**Header**: `Content-Type: application/json`<br /> **Header**: `Content-Type: application/json`<br />
**Content**: `{ "error": "Malformed JSON." }` **Content**: `{ "mandatory_fields": ["field1", "field2", "and so on"] }`
* **Code**: `400 Bad Request`<br /> * **Code**: `400 Invalid Index Type`
**Header**: `Content-Type: application/json`<br />
**Content**: `{ "error": "Mandatory field(s) not provided." }`
* **Sample Call**: TODO * **Sample Call**: TODO
* **Notes**: * **Notes**:
* Route numbering starts at zero. * Route numbering starts at zero.
@@ -252,13 +251,11 @@ Removes the route identified by `:id`.
* **URL**: `/routes/:id` * **URL**: `/routes/:id`
* **Method**: `DELETE` * **Method**: `DELETE`
* **Success Response**: * **Success Responses**:
* **Code**: `200 OK`<br /> * **Code**: `200 OK`<br />
**Content**: TODO **Content**: TODO
* **Error Response**: * **Error Responses**:
* **Code**: `404 Not Found`<br /> * **Code**: `404 Not Found`
**Header**: `Content-Type: application/json`<br />
**Content**: `{ "error": "Unknown route", "route_id": "{{ :id }}" }`
* **Sample Call**: TODO * **Sample Call**: TODO
* **Notes**: * **Notes**:
@@ -269,24 +266,24 @@ Handlers are in-memory data structures exposing the data of the current request
and response. and response.
Each handler is identified by a `handler_id` and provide access to the Each handler is identified by a `handler_id` and provide access to the
following keys: following resource paths:
``` ```
/ The root of the keys tree / The root of the resource paths tree
├─ request All information related to the HTTP request. Read-Only ├─ request All information related to the HTTP request. Read-Only
│ ├──── method Used HTTP Method (GET, POST) │ ├──── method Used HTTP Method (GET, POST)
│ ├──── path Complete URL path (URL-unquoted) │ ├──── path Complete URL path (URL-unquoted)
│ ├──── matches Previously matched URL path parts │ ├──── matches Previously matched URL path parts
│ │ └──── <entry> │ │ └──── <name>
│ ├──── params URL parameters (post ? symbol) │ ├──── params URL parameters (post ? symbol)
│ │ └──── <entry> │ │ └──── <name>
│ ├──── headers HTTP request headers │ ├──── headers HTTP request headers
│ │ └──── <entry> │ │ └──── <name>
│ ├──── cookies HTTP request cookie │ ├──── cookies HTTP request cookie
│ │ └──── <entry> │ │ └──── <name>
│ ├──── form form-urlencoded form fields │ ├──── form form-urlencoded form fields
│ │ └──── <entry> │ │ └──── <name>
│ └──── body HTTP request body │ └──── body HTTP request body
└─ response All information related to the HTTP request. Write-Only └─ response All information related to the HTTP request. Write-Only
@@ -294,7 +291,7 @@ following keys:
├──── body Response body. Mutually exclusive with response/stream ├──── body Response body. Mutually exclusive with response/stream
├──── stream Chunk-encoded body. Streamed response. Mutually exclusive with response/body ├──── stream Chunk-encoded body. Streamed response. Mutually exclusive with response/body
└──── headers HTTP response headers └──── headers HTTP response headers
└──── <entry> └──── <name>
``` ```
@@ -352,48 +349,40 @@ following keys:
`response` are write-only. `response` are write-only.
#### Get handler key #### Get handler resource
Returns the value of the requested key, or an error if the key doesn't exist or is invalid. Returns the value of the requested resource path, or an error if the resource path doesn't exist or is invalid.
* **URL**: `/handlers/{:handler_id}{:key}` * **URL**: `/handlers/{:handler_id}{:resource_path}`
* **Method**: `GET` * **Method**: `GET`
* **URL Params**: FIXME: We think that here should be options to cook the value in some way, or get it raw. * **URL Params**: FIXME: We think that here should be options to cook the value in some way, or get it raw.
* **Success Responses**: * **Success Responses**:
* **Code**: `200 OK`<br /> * **Code**: `200 OK`<br />
**Header**: `Content-Type: application/octet-stream`<br /> **Header**: `Content-Type: application/octet-stream`<br />
**Content**: The value for that key. Note that it may be empty. **Content**: The value of the resource. Note that it may be empty.
* **Error Responses**: * **Error Responses**:
* Key is invalid.<br /> **Code**: `400 Invalid Resource Path`<br />
**Code**: `400 Bad Request`<br /> **Notes**: Check the list of valid resource paths at the top of this section.
**Content**: None.<br /> * **Code**: `404 Not Found`
**Notes**: Check the list of valid keys at the top of this section.
* Entry not found.<br />
**Code**: `404 Not Found`<br />
**Content**: None.<br />
* **Sample Call**: TODO * **Sample Call**: TODO
* **Notes**: TODO * **Notes**: TODO
#### Overwrite the value for a handler key #### Overwrite the value of a resource
* **URL**: `/handlers/{:handler_id}{:key}` * **URL**: `/handlers/{:handler_id}{:resource_path}`
* **Method**: `PUT` * **Method**: `PUT`
* **URL Params**: FIXME: We think that here should be options to cook the value in some way, or pass it raw. * **URL Params**: FIXME: We think that here should be options to cook the value in some way, or pass it raw.
* **Data Params**: Binary payload. * **Data Params**: Binary payload.
* **Success Responses**: * **Success Responses**:
* **Code**: `200 OK` * **Code**: `200 OK`
* **Error Response**: * **Error Responses**:
* Key is invalid.<br /> * **Code**: `400 Invalid Payload`
**Code**: `400 Bad Request`<br /> * **Code**: `400 Invalid Resource Path`<br />
**Content**: None.<br /> **Notes**: Check the list of valid resource paths at the top of this section.
**Notes**: Check the list of valid keys at the top of this section. * **Code**: `404 Handler Not Found`
* Entry not found.<br /> * **Code**: `404 Name Not Found`<br />
**Code**: `404 Not Found`<br /> **Notes**: Although the resource path is correct, no such name is present in the request. For instance, `/request/headers/Foo`, when no `Foo` header is not present in the request.
**Content**: None.<br />
* Invalid value.<br />
**Code**: `400 Invalid Payload`<br />
**Content**: None.<br />
* **Sample Call**: * **Sample Call**:
* **Notes**: * **Notes**: