Skip to content

Commit 0f13c69

Browse files
committed
check whether we should try and convert an OpenAPI schema
1 parent 8f3cfac commit 0f13c69

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/schemaHandler.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class SchemaHandler {
1515
serverless.service?.provider?.apiGateway?.request?.schemas || {};
1616
this.documentation = serverless.service.custom.documentation;
1717
this.openAPI = openAPI;
18+
1819
this.shouldConvert = true;
19-
if (/(3\.1\.\d)/g(this.openAPI.openapi)) this.shouldConvert = false;
20+
if (/(3\.1\.\d)/g.test(this.openAPI.openapi)) this.shouldConvert = false;
2021

2122
this.modelReferences = {};
2223

@@ -159,11 +160,11 @@ class SchemaHandler {
159160
}
160161
);
161162

162-
this.logger.verbose(
163-
`dereferenced model: ${JSON.stringify(dereferencedSchema)}`
164-
);
165-
166163
if (this.shouldConvert) {
164+
this.logger.verbose(
165+
`dereferenced model: ${JSON.stringify(dereferencedSchema)}`
166+
);
167+
167168
this.logger.verbose(`converting model: ${name}`);
168169
const convertedSchemas = SchemaConvertor.convert(
169170
dereferencedSchema,
@@ -176,7 +177,13 @@ class SchemaHandler {
176177
return convertedSchemas;
177178
}
178179

179-
return dereferencedSchema;
180+
this.logger.verbose(
181+
`dereferenced model: ${JSON.stringify({
182+
schemas: { [name]: dereferencedSchema },
183+
})}`
184+
);
185+
186+
return { schemas: { [name]: dereferencedSchema } };
180187
}
181188

182189
async __dereferenceSchema(schema) {

0 commit comments

Comments
 (0)