Airtable to json-schema
Generate json-schema files for the BI events used by all kin systems.
Schemas are generated based on the definitions in Airtable.
Install
The easy way is to install from npm:
npm install @kinecosystem/airtable-to-json-schema
Another option is to clone this repo:
git clone git@github.com:kinecosystem/airtable-to-json-schema.git
And then build the project:
airtable-to-json-schema > npm install
airtable-to-json-schema > npm run build
Generate Json-Schema files
First thing you need is to create a config file, which needs to be a json file with the following structure:
{
"airtable": {
"base": "base id string",
"apiKey": "api key string"
},
"eventsDir": "path to event schemas out directory, default to ./events"
}
There's already a file like that waiting to be used: airtable-to-json-schema/config.examle.json
, so:
airtable-to-json-schema > cp ./config.examle.json ./config.json
Then edit config.json
and add the real values you'll be using and then run the app:
npm run generate
You can also pass the path to the config file in case you're using a file different than
airtable-to-json-schema/config.json
:
npm run generate /path/to/config/file.json
The generated json schema files will appear in the directory which path was included in the config.json
under eventsDir
, and if not set the default is airtable-to-json-schema/events
.
Generating language specific event files
Using the generated json-schema files, you can generate classes/interfaces to match the BI events for
your specific language.
For example, for typescript, using json-schema-to-typescript:
json2ts -i ./events/kin_balance_updated.json -o ./kin_balance_updated.d.ts
Other languages
- Java: jsonschema2pojo
- Python: warlock, python-jsonschema-objects
- Go: schematype, generate
- Objective-C: nidyx
And there's this tool: https://quicktype.io/ which lets you:
Instantly generate code from JSON