Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 96550cd

Browse files
committed
fix(apib): handle header without value during serialization
Fixes #584
1 parent 9156704 commit 96550cd

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

packages/apib-serializer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# API Elements: API Blueprint Serializer Changelog
22

3+
## TBD
4+
5+
### Bug Fixes
6+
7+
- Fixes handling of headers which do not contain values.
8+
39
## 0.16.2 (2020-08-31)
410

511
### Enhancements

packages/apib-serializer/template.nunjucks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ FORMAT: 1A
1919
+ Headers
2020

2121
{% for header in example.headers.exclude('Content-Type').elements %}
22-
{{ header.key.toValue() }}: {{ header.value.toValue() }}{% endfor %}
22+
{{ header.key.toValue() }}:{% if header.value %} {{ header.value.toValue() }}{% endif %}{% endfor %}
2323

2424
{% endif %}
2525
{% if example.dataStructure %}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FORMAT: 1A
2+
3+
# API Documentation
4+
5+
### /
6+
7+
#### GET
8+
9+
+ Request
10+
11+
+ Headers
12+
13+
Accept:
14+
15+
+ Response 204
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"element": "parseResult",
3+
"content": [
4+
{
5+
"element": "category",
6+
"meta": {
7+
"classes": {
8+
"element": "array",
9+
"content": [
10+
{
11+
"element": "string",
12+
"content": "api"
13+
}
14+
]
15+
}
16+
},
17+
"content": [
18+
{
19+
"element": "resource",
20+
"attributes": {
21+
"href": {
22+
"element": "string",
23+
"content": "/"
24+
}
25+
},
26+
"content": [
27+
{
28+
"element": "transition",
29+
"content": [
30+
{
31+
"element": "httpTransaction",
32+
"content": [
33+
{
34+
"element": "httpRequest",
35+
"attributes": {
36+
"method": {
37+
"element": "string",
38+
"content": "GET"
39+
},
40+
"headers": {
41+
"element": "httpHeaders",
42+
"content": [
43+
{
44+
"element": "member",
45+
"content": {
46+
"key": {
47+
"element": "string",
48+
"content": "Accept"
49+
}
50+
}
51+
}
52+
]
53+
}
54+
}
55+
},
56+
{
57+
"element": "httpResponse",
58+
"attributes": {
59+
"statusCode": {
60+
"element": "string",
61+
"content": "204"
62+
}
63+
}
64+
}
65+
]
66+
}
67+
]
68+
}
69+
]
70+
}
71+
]
72+
}
73+
]
74+
}

0 commit comments

Comments
 (0)