Skip to content

Commit

Permalink
Implement curlify jinja template and add it to markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamaia committed Apr 22, 2020
1 parent dbd4b9e commit eba2ecd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions scanapi/reporter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import logging
import curlify

from jinja2 import Environment, PackageLoader, select_autoescape

Expand All @@ -19,6 +20,7 @@ def write(self, responses):

# self.hide_headers_info(responses) TODO: Move to RequestNode.run
env = Environment(loader=PackageLoader("scanapi", "templates"))
env.filters["curlify"] = curlify.to_curl
template = env.get_template(f"{self.reporter}.jinja")
content = template.render(responses=responses)

Expand Down
14 changes: 13 additions & 1 deletion scanapi/templates/markdown.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

{% for response in responses %}
{% set request = response.request %}
## {{ request.method }} {{ request.url }}
## {{ request.method }} `{{ request.path_url }}`

### Request

Full URL: {{ request.url }}

#### Headers

{% if request.headers|length > 0 %}
Expand All @@ -18,6 +20,16 @@
None
{% endif %}

#### cURL

<details><summary></summary><p>

```
{{request|curlify}}
```

</p></details>

### Response

#### Metadata
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

requirements = [
"click >= 7.0",
"curlify >= 2.2.1",
"jinja2 >= 2.10.3",
"pyyaml >= 5.1.1",
"requests >= 2.22.0",
Expand Down

0 comments on commit eba2ecd

Please sign in to comment.