Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #20: remove patternProperties JSON schema keyword #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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