diff --git a/package.json b/package.json index 8871f86..56531d9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "zap-api-docs", "version": "1.0.0", "scripts": { - "build": "widdershins --search false --language_tabs 'shell:Shell' 'java:Java' 'python:Python' --summary openapi.yaml source/includes/apis.md" + "build": "widdershins -u widdershins/templates/ --search false --language_tabs 'shell:Shell' 'java:Java' 'python:Python' --summary openapi.yaml source/includes/apis.md" }, "dependencies": { "widdershins": "^3.6.7" diff --git a/widdershins/templates/code_python.dot b/widdershins/templates/code_python.dot new file mode 100644 index 0000000..2c1f52b --- /dev/null +++ b/widdershins/templates/code_python.dot @@ -0,0 +1,10 @@ +import requests +{{?data.allHeaders.length}}headers = { +{{~data.allHeaders :p:index}} '{{=p.name}}': {{=p.exampleValues.json}}{{?index < data.allHeaders.length-1}},{{?}} +{{~}}} +{{?}} +r = requests.{{=data.method.verb}}('{{=data.url}}'{{? data.requiredParameters.length}}, params={ +{{~ data.requiredParameters :p:index}} '{{=p.name}}': {{=p.exampleValues.json}}{{? data.requiredParameters.length-1 != index }},{{?}}{{~}} +}{{?}}{{?data.allHeaders.length}}, headers = headers{{?}}) + +{{?data.url.includes("/JSON/")}}print(r.json()){{?? true }}print(r.content){{?}}