Skip to content

Commit

Permalink
feat(oas3): remove unsupported warning for OpenAPI 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kylef committed Feb 23, 2021
1 parent f4d25cd commit c688d11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/openapi3-parser/lib/parser/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { isString } = require('../predicates');

const semanticVersionRE = /^(\d+)\.(\d+).(\d+)$/;

const supportedMinorVersion = 0;
const supportedMinorVersion = 1;
const supportedMajorVersion = 3;

// Parse the OpenAPI Version member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('#parseOpenAPIObject', () => {

const parseResult = parse(context, object);

expect(parseResult.warnings.get(1).toValue()).to.equal("'OpenAPI Object' contains unsupported key 'webhooks'");
expect(parseResult).to.contain.warning("'OpenAPI Object' contains unsupported key 'webhooks'");
});

it('provides warning for invalid key jsonSchemaDialect in OpenAPI 3.0', () => {
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('#parseOpenAPIObject', () => {

const parseResult = parse(context, object);

expect(parseResult.warnings.get(1).toValue()).to.equal("'OpenAPI Object' contains unsupported key 'jsonSchemaDialect'");
expect(parseResult).to.contain.warning("'OpenAPI Object' contains unsupported key 'jsonSchemaDialect'");
});

it('provides warning for invalid key webhooks in OpenAPI 3.0', () => {
Expand Down
15 changes: 12 additions & 3 deletions packages/openapi3-parser/test/unit/parser/openapi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ describe('#parseOpenAPI', () => {
expect(parseResult.get(0).value.toValue()).to.equal('3.0.0');
});

it('allows openapi 3.1.0', () => {
const openapi = new namespace.elements.Member('openapi', '3.1.0');

const parseResult = parseOpenAPI(context, openapi);
expect(parseResult).to.be.instanceof(namespace.elements.ParseResult);
expect(parseResult).to.not.contain.annotations;
expect(parseResult.get(0).value.toValue()).to.equal('3.1.0');
});

it('allows openapi patch version 3.0.11', () => {
const openapi = new namespace.elements.Member('openapi', '3.0.11');

Expand All @@ -56,12 +65,12 @@ describe('#parseOpenAPI', () => {
});

it('warns for unsuported minor versions', () => {
const openapi = new namespace.elements.Member('openapi', '3.1.0');
const openapi = new namespace.elements.Member('openapi', '3.2.0');

const parseResult = parseOpenAPI(context, openapi);
expect(parseResult).to.be.instanceof(namespace.elements.ParseResult);
expect(parseResult).to.contain.warning("Version '3.1.0' is not fully supported");
expect(parseResult.get(0).value.toValue()).to.equal('3.1.0');
expect(parseResult).to.contain.warning("Version '3.2.0' is not fully supported");
expect(parseResult.get(0).value.toValue()).to.equal('3.2.0');
});

it('adds the version to context', () => {
Expand Down

0 comments on commit c688d11

Please sign in to comment.