Show all responses, not just the successful one

This still filters out responses lacking either a description or an
example
pull/977/head
Daniel Wagner-Hall 9 years ago
parent 0414ff4cc3
commit 94b13c0121

@ -46,6 +46,19 @@ Example request::
{{endpoint.example.req | indent_block(2)}}
Example response::
{% if endpoint.example.responses|length > 0 -%}
Response{{"s" if endpoint.example.responses|length > 1 else "" }}:
{{endpoint.example.res | indent_block(2)}}
{% endif -%}
{% for res in endpoint.example.responses -%}
**Status code {{res["code"]}}:**
{{res["description"]}}
Example::
{{res["example"] | indent_block(2)}}
{% endfor %}

@ -177,11 +177,17 @@ class MatrixUnits(Units):
endpoint["req_param_by_loc"][p["loc"]] = []
endpoint["req_param_by_loc"][p["loc"]].append(p)
# add example response if it has one
res = single_api["responses"][200] # get the 200 OK response
endpoint["example"]["res"] = res.get("examples", {}).get(
"application/json", ""
)
endpoint["example"]["responses"] = [] # Ordered list of maps
for code, res in single_api["responses"].items():
description = res.get("description", "")
example = res.get("examples", {}).get("application/json", "")
if description and example:
endpoint["example"]["responses"].append({
"code": code,
"description": description,
"example": example,
})
# form example request if it has one. It "has one" if all params
# have either "x-example" or a "schema" with an "example".
params_missing_examples = [

Loading…
Cancel
Save