bugdown: Show example value for path params in curl example.

This commit is contained in:
Vishnu Ks
2019-10-03 13:59:28 +00:00
committed by Tim Abbott
parent a03765bbe2
commit cb64fc8732
2 changed files with 31 additions and 12 deletions

View File

@@ -153,7 +153,15 @@ def generate_curl_example(endpoint: str, method: str,
openapi_entry = openapi_spec.spec()['paths'][endpoint][method.lower()]
openapi_params = openapi_entry.get("parameters", [])
curl_first_line_parts = ["curl"] + curl_method_arguments(endpoint, method,
format_dict = {}
for param in openapi_params:
if param["in"] != "path":
continue
example_value = get_openapi_param_example_value_as_string(endpoint, method, param)
format_dict[param["name"]] = example_value
example_endpoint = endpoint.format_map(format_dict)
curl_first_line_parts = ["curl"] + curl_method_arguments(example_endpoint, method,
api_url)
lines.append(" ".join(curl_first_line_parts))