diff --git a/package-lock.json b/package-lock.json index d916752..ae1633b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@apiture/openapi-down-convert", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 09634fc..f2ef482 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apiture/openapi-down-convert", - "version": "0.11.0", + "version": "0.12.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 4bab609..d72013a 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -251,7 +251,7 @@ export class Converter { } } removeUnsupportedSchemaKeywords() { - const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties']; + const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties', 'contentMediaType']; 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 1c74e13..8746255 100644 --- a/test/converter.spec.ts +++ b/test/converter.spec.ts @@ -355,6 +355,47 @@ describe('resolver test suite', () => { done(); }); + test('Remove contentMediaType keywords', (done) => { + const input = { + openapi: '3.1.0', + components: { + schemas: { + a: { + type: 'object', + unevaluatedProperties: false, + properties: { + b: { + type: 'string', + contentMediaType: 'application/pdf', + maxLength: 5000000 + }, + }, + }, + }, + }, + }; + const expected = { + openapi: '3.0.3', + components: { + schemas: { + a: { + type: 'object', + properties: { + b: { + type: 'string', + maxLength: 5000000 + }, + }, + }, + }, + }, + }; + const converter = new Converter(input, { verbose: true }); + const converted: any = converter.convert(); + expect(converted).toEqual(expected); + done(); + }); + test('Remove webhooks object', (done) => { const input = { diff --git a/test/data/openapi.yaml b/test/data/openapi.yaml index 8a4fd62..e8f77a2 100644 --- a/test/data/openapi.yaml +++ b/test/data/openapi.yaml @@ -63,6 +63,12 @@ paths: application/json: schema: $ref: '#/components/schemas/preferences' + application/pdf: + schema: + type: string + contentMediaType: application/json + contentEncoding: base64 + maxLength: 5000000 '400': $ref: '#/components/responses/400' '401':