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

Commit 64f7bf4

Browse files
committed
fix(oas3): support header references
1 parent cbd8ea0 commit 64f7bf4

File tree

5 files changed

+186
-2
lines changed

5 files changed

+186
-2
lines changed

packages/fury-adapter-oas3-parser/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
- Added additional information to YAML parsing errors where available to make
1414
the errors more understandable.
1515

16+
- Fix referencing a headers component. Previously this would return an error
17+
that the headers components was undefined.
18+
1619
## 0.7.2 (2019-04-01)
1720

1821
### Bug Fixes

packages/fury-adapter-oas3-parser/lib/parser/oas/parseComponentsObject.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const {
99
} = require('../annotations');
1010
const parseObject = require('../parseObject');
1111
const pipeParseResult = require('../../pipeParseResult');
12-
const parseMap = require('../parseMap');
1312
const parseSchemaObject = require('./parseSchemaObject');
1413
const parseParameterObject = require('./parseParameterObject');
1514
const parseResponseObject = require('./parseResponseObject');
@@ -166,7 +165,7 @@ function parseComponentsObject(context, element) {
166165
[hasKey('responses'), parseComponentObjectMember(parseResponseObject)],
167166
[hasKey('requestBodies'), parseComponentObjectMember(parseRequestBodyObject)],
168167
[hasKey('examples'), parseComponentObjectMember(parseExampleObject)],
169-
[hasKey('headers'), parseMap(context, name, 'headers', parseHeaderObject)],
168+
[hasKey('headers'), parseComponentObjectMember(parseHeaderObject)],
170169
[hasKey('securitySchemes'), parseSecuritySchemes],
171170

172171
[isUnsupportedKey, createUnsupportedMemberWarning(namespace, name)],

packages/fury-adapter-oas3-parser/test/integration/components-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('components', () => {
3434
return testParseFixture(file);
3535
});
3636

37+
it("'Response Object' headers references", () => {
38+
const file = path.join(fixtures, 'response-object-headers');
39+
return testParseFixture(file);
40+
});
41+
3742
it("'Schema Object' circular references", () => {
3843
const file = path.join(fixtures, 'schema-object-circular');
3944
return testParseFixture(file);
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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+
"title": {
17+
"element": "string",
18+
"content": "Headers Components"
19+
}
20+
},
21+
"attributes": {
22+
"version": {
23+
"element": "string",
24+
"content": "1.0.0"
25+
}
26+
},
27+
"content": [
28+
{
29+
"element": "resource",
30+
"attributes": {
31+
"href": {
32+
"element": "string",
33+
"content": "/user"
34+
}
35+
},
36+
"content": [
37+
{
38+
"element": "transition",
39+
"meta": {
40+
"title": {
41+
"element": "string",
42+
"content": "View the current User"
43+
}
44+
},
45+
"content": [
46+
{
47+
"element": "httpTransaction",
48+
"content": [
49+
{
50+
"element": "httpRequest",
51+
"attributes": {
52+
"method": {
53+
"element": "string",
54+
"content": "GET"
55+
}
56+
}
57+
},
58+
{
59+
"element": "httpResponse",
60+
"attributes": {
61+
"headers": {
62+
"element": "httpHeaders",
63+
"content": [
64+
{
65+
"element": "member",
66+
"content": {
67+
"key": {
68+
"element": "string",
69+
"content": "X-Rate-Limit-Limit"
70+
},
71+
"value": {
72+
"element": "string"
73+
}
74+
}
75+
}
76+
]
77+
},
78+
"statusCode": {
79+
"element": "string",
80+
"content": "200"
81+
}
82+
},
83+
"content": [
84+
{
85+
"element": "copy",
86+
"content": "hi"
87+
}
88+
]
89+
}
90+
]
91+
}
92+
]
93+
}
94+
]
95+
}
96+
]
97+
},
98+
{
99+
"element": "annotation",
100+
"meta": {
101+
"classes": {
102+
"element": "array",
103+
"content": [
104+
{
105+
"element": "string",
106+
"content": "warning"
107+
}
108+
]
109+
}
110+
},
111+
"attributes": {
112+
"sourceMap": {
113+
"element": "array",
114+
"content": [
115+
{
116+
"element": "sourceMap",
117+
"content": [
118+
{
119+
"element": "array",
120+
"content": [
121+
{
122+
"element": "number",
123+
"attributes": {
124+
"line": {
125+
"element": "number",
126+
"content": 18
127+
},
128+
"column": {
129+
"element": "number",
130+
"content": 7
131+
}
132+
},
133+
"content": 352
134+
},
135+
{
136+
"element": "number",
137+
"attributes": {
138+
"line": {
139+
"element": "number",
140+
"content": 18
141+
},
142+
"column": {
143+
"element": "number",
144+
"content": 18
145+
}
146+
},
147+
"content": 11
148+
}
149+
]
150+
}
151+
]
152+
}
153+
]
154+
}
155+
},
156+
"content": "'Header Object' contains unsupported key 'description'"
157+
}
158+
]
159+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
openapi: 3.0.0
2+
info:
3+
version: 1.0.0
4+
title: Headers Components
5+
paths:
6+
/user:
7+
get:
8+
summary: View the current User
9+
responses:
10+
'200':
11+
description: hi
12+
headers:
13+
X-Rate-Limit-Limit:
14+
$ref: '#/components/headers/X-Rate-Limit-Limit'
15+
components:
16+
headers:
17+
X-Rate-Limit-Limit:
18+
description: The number of allowed requests in the current period

0 commit comments

Comments
 (0)