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

Commit 88bcb56

Browse files
author
Marco Friso
committed
fix(oas3): add format link when OpenAPI property is not a string
1 parent f52cd03 commit 88bcb56

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/openapi3-parser/lib/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function parse(source, context) {
144144
R.prop('content'),
145145
R.find(R.both(isMember, hasKey('openapi'))),
146146
R.path(['content', 'value']),
147-
R.and(isString, R.prop('content'))
147+
R.ifElse(isString, R.prop('content'), R.always('3.0.3'))
148148
), R.always('3.0.3')
149149
)(document);
150150

packages/openapi3-parser/test/unit/parser-test.js

+11
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,15 @@ describe('#parse', () => {
6262
expect(link.title.toValue()).to.equal('OpenAPI 3.0.3');
6363
expect(link.href.toValue()).to.equal('https://spec.openapis.org/oas/v3.0.3');
6464
});
65+
66+
it('add OpenAPI 3.0.3 format link when OpenAPI property is not a string', () => {
67+
const source = 'openapi: {"test": "3.0.0"}\ninfo: {title: My API, version: 1.0.0}\npaths: {}\n';
68+
const parseResult = parse(source, context);
69+
70+
const link = parseResult.links.get(0);
71+
expect(link).to.be.instanceof(Link);
72+
expect(link.relation.toValue()).to.equal('via');
73+
expect(link.title.toValue()).to.equal('OpenAPI 3.0.3');
74+
expect(link.href.toValue()).to.equal('https://spec.openapis.org/oas/v3.0.3');
75+
});
6576
});

0 commit comments

Comments
 (0)