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

Commit 673d073

Browse files
authored
Clone parameter to prevent duplicate instance in tree (#228)
Clone parameter to prevent duplicate instance in tree
2 parents 95df0a9 + 4b16fd6 commit 673d073

12 files changed

+1137
-31
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Fury OAS3 Parser Changelog
22

3+
## Master
4+
5+
### Bug Fixes
6+
7+
- Prevents an exception being raised when using `freeze()` on the parse result
8+
returned by the parser when you reference a parameter component multiple
9+
times in an OpenAPI Document.
10+
311
## 0.7.4 (2019-04-12)
412

513
### Enhancements

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function parseOperationObject(context, path, member) {
156156
R.reject(member => !headers.include(member.key.toValue()).isEmpty, headerParameters.content)
157157
);
158158

159-
request.headers = headers;
159+
request.headers = headers.clone();
160160
});
161161
}
162162
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function parseParameterObjects(context, name, array) {
2929

3030
// Convert an array of parameters into the correct types
3131
const convertParameters = R.cond([
32-
[isPathOrQuery, member => new namespace.elements.HrefVariables(member.value.content)],
32+
[isPathOrQuery, member => new namespace.elements.HrefVariables(member.value.clone().content)],
3333
// FIXME when headers and cookies are supported these should be converted
34-
[R.T, member => member],
34+
[R.T, member => member.clone()],
3535
]);
3636

3737
const parseParameters = pipeParseResult(namespace,

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

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,72 @@ const testParseFixture = require('./testParseFixture');
44
const fixtures = path.join(__dirname, 'fixtures', 'components');
55

66
describe('components', () => {
7-
it("'Path Item Object' parameter references", () => {
8-
const file = path.join(fixtures, 'path-item-object-parameters');
9-
return testParseFixture(file);
10-
});
7+
describe('Path Item Object', () => {
8+
it('handles parameter references', () => {
9+
const file = path.join(fixtures, 'path-item-object-parameters');
10+
return testParseFixture(file);
11+
});
1112

12-
it("'Path Item Object' parameter referencing unsupported parameter", () => {
13-
const file = path.join(fixtures, 'path-item-object-parameters-unsupported-parameter');
14-
return testParseFixture(file);
15-
});
13+
it('handles multiple references to same parameter', () => {
14+
const file = path.join(fixtures, 'path-item-object-parameters-multiple');
15+
return testParseFixture(file);
16+
});
1617

17-
it("'Media Type Object' schema references", () => {
18-
const file = path.join(fixtures, 'media-type-object-schema');
19-
return testParseFixture(file);
18+
it('handles parameter referencing unsupported parameter', () => {
19+
const file = path.join(fixtures, 'path-item-object-parameters-unsupported-parameter');
20+
return testParseFixture(file);
21+
});
2022
});
2123

22-
it("'Media Type Object' examples references", () => {
23-
const file = path.join(fixtures, 'media-type-object-examples');
24-
return testParseFixture(file);
25-
});
24+
describe('Media Type Object', () => {
25+
it('handles schema references', () => {
26+
const file = path.join(fixtures, 'media-type-object-schema');
27+
return testParseFixture(file);
28+
});
2629

27-
it("'Responses Object' response references", () => {
28-
const file = path.join(fixtures, 'responses-object-response');
29-
return testParseFixture(file);
30-
});
30+
it('handles multiple references to same schema', () => {
31+
const file = path.join(fixtures, 'media-type-object-schema-multiple');
32+
return testParseFixture(file);
33+
});
3134

32-
it("'Responses Object' response references with schema", () => {
33-
const file = path.join(fixtures, 'responses-object-response-with-schema');
34-
return testParseFixture(file);
35+
it('handles examples references', () => {
36+
const file = path.join(fixtures, 'media-type-object-examples');
37+
return testParseFixture(file);
38+
});
3539
});
3640

37-
it("'Responses Object' respomnse references with headers", () => {
38-
const file = path.join(fixtures, 'responses-object-response-with-headers');
39-
return testParseFixture(file);
41+
describe('Responses Object', () => {
42+
it('handles response references', () => {
43+
const file = path.join(fixtures, 'responses-object-response');
44+
return testParseFixture(file);
45+
});
46+
47+
it('handles multiple references to same response', () => {
48+
const file = path.join(fixtures, 'responses-object-response-multiple');
49+
return testParseFixture(file);
50+
});
51+
52+
it('handles response references with schema', () => {
53+
const file = path.join(fixtures, 'responses-object-response-with-schema');
54+
return testParseFixture(file);
55+
});
56+
57+
it('handles responses references with headers', () => {
58+
const file = path.join(fixtures, 'responses-object-response-with-headers');
59+
return testParseFixture(file);
60+
});
4061
});
4162

42-
it("'Response Object' headers references", () => {
43-
const file = path.join(fixtures, 'response-object-headers');
44-
return testParseFixture(file);
63+
describe('Response Object', () => {
64+
it('handles headers references', () => {
65+
const file = path.join(fixtures, 'response-object-headers');
66+
return testParseFixture(file);
67+
});
68+
69+
it('handles multiple references to same header', () => {
70+
const file = path.join(fixtures, 'response-object-headers-multiple');
71+
return testParseFixture(file);
72+
});
4573
});
4674

4775
it("'Schema Object' circular references", () => {

0 commit comments

Comments
 (0)