@windingtree/wt-search-api
Version:
NodeJS app that enables quick search over data from Winding Tree platform
29 lines (25 loc) • 814 B
JavaScript
const openapi2schema = require('openapi2schema');
const fs = require('fs');
/**
* Usage: `npm run regenerate-schemas`
* Use this after updating swagger.yaml to update json object schemas used for validation.
*
* Build will fail if changes are found at build time.
* $ [ -z "$(git diff --name-status --diff-filter=M src/services/validators/)" ] || exit 1
*/
const SCHEMA_DEFS = [
{
order: 1,
filePath: 'src/services/validators/notification-schema.json',
},
];
openapi2schema('docs/swagger.yaml', { async: true }, (err, result) => {
if (err) {
// openapi2schema fails
console.error(err);
} else {
for (let definition of SCHEMA_DEFS) {
fs.writeFileSync(definition.filePath, JSON.stringify(result['/notifications/{subscription_token}'].post.body, null, ' '));
}
}
});