Skip to content

Commit 99e45e9

Browse files
authored
Merge pull request #21 from DavidBiesack/issue-20-remove-additionalProperties-json-schema-keyword
Fixes #20: remove patternProperties JSON schema keyword
2 parents 997ed6f + d4c7daf commit 99e45e9

4 files changed

Lines changed: 53 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apiture/openapi-down-convert",
3-
"version": "0.12.0",
3+
"version": "0.13.0",
44
"description": "Tool to down convert OpenAPI 3.1 to OpenAPI 3.0",
55
"main": "lib/src/index.js",
66
"bin": {

src/converter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export class Converter {
251251
}
252252
}
253253
removeUnsupportedSchemaKeywords() {
254-
const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties', 'contentMediaType'];
254+
const keywordsToRemove = ['$id', '$schema', 'unevaluatedProperties', 'contentMediaType', 'patternProperties'];
255255
const schemaVisitor: SchemaVisitor = (schema: SchemaObject): SchemaObject => {
256256
keywordsToRemove.forEach((key) => {
257257
if (schema.hasOwnProperty(key)) {

test/converter.spec.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,55 @@ describe('resolver test suite', () => {
355355
done();
356356
});
357357

358+
359+
test('Remove patternProperties keywords', (done) => {
360+
const input = {
361+
openapi: '3.1.0',
362+
components: {
363+
schemas: {
364+
a: {
365+
type: 'object',
366+
properties: {
367+
s: {
368+
type: 'string',
369+
},
370+
},
371+
patternProperties: {
372+
"^[a-z{2}-[A-Z]{2,3}]$": {
373+
type: 'object',
374+
unevaluatedProperties: false,
375+
properties: {
376+
t: {
377+
type: 'string',
378+
},
379+
},
380+
},
381+
},
382+
},
383+
},
384+
},
385+
};
386+
const expected = {
387+
openapi: '3.0.3',
388+
components: {
389+
schemas: {
390+
a: {
391+
type: 'object',
392+
properties: {
393+
s: {
394+
type: 'string',
395+
},
396+
},
397+
},
398+
},
399+
},
400+
};
401+
const converter = new Converter(input, { verbose: true });
402+
const converted: any = converter.convert();
403+
expect(converted).toEqual(expected);
404+
done();
405+
});
406+
358407
test('Remove contentMediaType keywords', (done) => {
359408
const input = {
360409
openapi: '3.1.0',

0 commit comments

Comments
 (0)