Skip to content

Commit

Permalink
feat(quoteSummary): all submodules, using validation type coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Feb 1, 2021
1 parent 3206146 commit 3970132
Show file tree
Hide file tree
Showing 15 changed files with 677 additions and 1,771 deletions.
35 changes: 35 additions & 0 deletions bin/modify-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

const fs = require('fs');
const schemaWalker = require('oas-schema-walker');

const chunks = [];
process.stdin.on('readable', () => {
let chunk;
while (null !== (chunk = process.stdin.read()))
chunks.push(chunk);
});

process.stdin.on('end', () => {

const schema = JSON.parse(chunks.join(''));

//const schema = JSON.parse(fs.readFileSync('./schema.json'));

function callback(schema, parent, state) {
if (schema.type === 'number') {
delete schema.type;
schema.yahooFinanceType = 'number';
} else if (schema.type === 'string' && schema.format === 'date-time') {
delete schema.format;
delete schema.type;
schema.yahooFinanceType = 'date';
}
}

for (let key of Object.keys(schema.definitions))
schemaWalker.walkSchema(schema.definitions[key], {}, {}, callback);


process.stdout.end(JSON.stringify(schema, null, 2) + '\n');
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "eslint",
"test": "jest",
"coverage": "jest --coverage",
"generateSchema": "ts-json-schema-generator -p 'src/**/*.ts' -t '*' > schema.json",
"generateSchema": "ts-json-schema-generator -p 'src/**/*.ts' -t '*' | node bin/modify-schema.js > schema.json",
"prepublishOnly": "tsc && yarn generateSchema"
},
"files": [
Expand All @@ -37,6 +37,7 @@
"@types/jest": "26.0.20",
"eslint": "7.19.0",
"jest": "26.6.3",
"oas-schema-walker": "^1.1.5",
"semantic-release": "17.3.7",
"ts-jest": "26.5.0",
"ts-json-schema-generator": "0.83.2",
Expand Down
Loading

0 comments on commit 3970132

Please sign in to comment.