Show all responses, not just the successful one
This still filters out responses lacking either a description or an example
This commit is contained in:
parent
0414ff4cc3
commit
94b13c0121
2 changed files with 26 additions and 7 deletions
|
@ -46,6 +46,19 @@ Example request::
|
||||||
|
|
||||||
{{endpoint.example.req | indent_block(2)}}
|
{{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"]] = []
|
||||||
endpoint["req_param_by_loc"][p["loc"]].append(p)
|
endpoint["req_param_by_loc"][p["loc"]].append(p)
|
||||||
|
|
||||||
# add example response if it has one
|
endpoint["example"]["responses"] = [] # Ordered list of maps
|
||||||
res = single_api["responses"][200] # get the 200 OK response
|
for code, res in single_api["responses"].items():
|
||||||
endpoint["example"]["res"] = res.get("examples", {}).get(
|
description = res.get("description", "")
|
||||||
"application/json", ""
|
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
|
# form example request if it has one. It "has one" if all params
|
||||||
# have either "x-example" or a "schema" with an "example".
|
# have either "x-example" or a "schema" with an "example".
|
||||||
params_missing_examples = [
|
params_missing_examples = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue