diff --git a/package-lock.json b/package-lock.json index ae1633b..1b6c65b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apiture/openapi-down-convert", - "version": "0.12.0", + "version": "0.13.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@apiture/openapi-down-convert", - "version": "0.11.0", + "version": "0.13.0", "license": "ISC", "dependencies": { "commander": "^9.4.1", diff --git a/package.json b/package.json index f2ef482..072a3b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apiture/openapi-down-convert", - "version": "0.12.0", + "version": "0.13.0", "description": "Tool to down convert OpenAPI 3.1 to OpenAPI 3.0", "main": "lib/src/index.js", "bin": { diff --git a/src/converter.ts b/src/converter.ts index d72013a..07c3358 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -251,7 +251,7 @@ export class Converter { } } removeUnsupportedSchemaKeywords() { - const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties', 'contentMediaType']; + const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties', 'contentMediaType', 'patternProperties']; const schemaVisitor: SchemaVisitor = (schema: SchemaObject): SchemaObject => { keywordsToRemove.forEach((key) => { if (schema.hasOwnProperty(key)) { diff --git a/test/converter.spec.ts b/test/converter.spec.ts index 8746255..0b2f582 100644 --- a/test/converter.spec.ts +++ b/test/converter.spec.ts @@ -355,6 +355,55 @@ describe('resolver test suite', () => { done(); }); + + test('Remove patternProperties keywords', (done) => { + const input = { + openapi: '3.1.0', + components: { + schemas: { + a: { + type: 'object', + properties: { + s: { + type: 'string', + }, + }, + patternProperties: { + "^[a-z{2}-[A-Z]{2,3}]$": { + type: 'object', + unevaluatedProperties: false, + properties: { + t: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }; + const expected = { + openapi: '3.0.3', + components: { + schemas: { + a: { + type: 'object', + properties: { + s: { + type: 'string', + }, + }, + }, + }, + }, + }; + const converter = new Converter(input, { verbose: true }); + const converted: any = converter.convert(); + expect(converted).toEqual(expected); + done(); + }); + test('Remove contentMediaType keywords', (done) => { const input = { openapi: '3.1.0',