Heading image

Building on from previous posts on a spike on JSON Schema, we will continue in this one by looking at an alternative library to the json-schema-to-typescript the library previously explored.

Setting Up

For book.json, add the following. It will follow a similar JSON schema we've used previously with the Book but a few changes, so are sure to copy-paste it across.

Writing out the script

index.js will look like the following:

In the above script, we are going to generate TypeScript and Python output for the sake of demonstration.

Running the generator

Run node index.js and you will get the following output for TypeScript and Python respectively:

The Python output:

Hooray! We can cut a lot of fluff with these helpers.

Resources And Further Reading

  1. QuickType

Image credit: Alessio Rinella

Originally posted on my blog.

Senior Engineer @ Culture Amp. Tinkerer and professional self-isolator in 2020.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store