Compile enrolla customer schemas to classes. Forked and based on https://github.com/bcherny/json-schema-to-typescript
Input:
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
},
"hairColor": {
"enum": ["black", "brown", "blue"],
"type": "string"
}
},
"additionalProperties": false,
"required": ["firstName", "lastName"]
}
Output:
import { ConfigClient } from '@enrolla/enrolla-ts'
export class Person {
constructor(private objectId: string) {}
firstName(): string {
return ConfigClient.get(this.objectId, 'firstName')
}
lastName(): string {
return ConfigClient.get(this.objectId, 'lastName')
}
/**
* Age in years
*/
age(): number | undefined {
return ConfigClient.get(this.objectId, 'age')
}
hairColor(): ('black' | 'brown' | 'blue') | undefined {
return ConfigClient.get(this.objectId, 'hairColor')
}
}
# Using Yarn:
yarn add @enrolla/cli --dev
# Or, using NPM:
npm install @enrolla/cli --save-dev
enrolla-cli -i schemas/ -o configs/