3 ms·
You are mistaken: https://ajv.js.org/guide/typescript.html#utility-types-for-schemas https://ajv.js.org/guide/typescript.html#utility-types-for-s...
by shadowfiend 2y ago
You are mistaken: https://ajv.js.org/guide/typescript.html#utility-types-for-schemas https://ajv.js.org/guide/typescript.html#utility-types-for-s...
- petesergeant 2y agoThat seems to show that you have to bring your own types for JSON Schema still, as evidenced by their example both explicitly defining the interface and then passing that it as an argument. I wasn’t aware however of JSON Type Definitions, which hadn’t been invented last time I released software with Ajv, but it does appear to be able to reflect those as well as validate from them, so thank you for showing me that.
- shadowfiend 2y agoAh, I think I misunderstood you. Yes, this does mean that you need something else to define the typescript to json schema conversion—either by using another tool or by starting from json schema and getting to the typescript types you want. Feels like it’s worth that trade off to have a consistent experience consuming other APIs as well, but I could be wrong; I think so far I’ve only used it when I need to consume APIs rather than produce them.