Skip to content

Commit

Permalink
Merge pull request #21 from DavidBiesack/issue-20-remove-additionalPr…
Browse files Browse the repository at this point in the history
…operties-json-schema-keyword

Fixes #20: remove patternProperties JSON schema keyword
  • Loading branch information
DavidBiesack authored Mar 15, 2024
2 parents 997ed6f + d4c7daf commit 99e45e9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
49 changes: 49 additions & 0 deletions test/converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 99e45e9

Please sign in to comment.