0.0.26 • Published 2 years ago
io-ts-from-json-schema v0.0.26
io-ts-from-json-schema
Iotsfjs is a static code generation utility used for converting json schema files into static TypeScript types and io-ts runtime validators.
Basic Use
npm install -g io-ts-from-json-schema typescript
iotsfjs --inputFile schema.json --outputDir output
Usage Example
# Create a Project
mkdir example && cd example
npm init -f && npm install --peer fp-ts io-ts io-ts-types
# Create a Schema File
npm install --peer maas-schemas-ts
mkdir -p ./schemas/examples && echo '{
"$id": "http://example.com/iotsfjs/examples/user.json",
"description": "Example user schema with an external dependency",
"type": "object",
"definitions": {
"name": {
"description": "Human-readable name of the user",
"type": "string"
}
},
"properties": {
"name": {
"$ref": "#/definitions/name"
},
"phone": {
"$ref": "http://maasglobal.com/core/components/common.json#/definitions/phone"
}
},
"required": ["name", "phone"],
"additionalProperties": false,
"examples": [
{
"name": "Joe User",
"phone": "+358407654321"
}
]
}' > ./schemas/examples/user.json
# Generate TypeScript Code
npm install --dev io-ts-from-json-schema typescript
./node_modules/.bin/iotsfjs --inputFile 'schemas/**/*.json' --outputDir src --base http://example.com/iotsfjs/ --import http://maasglobal.com/^maas-schemas-ts/lib/
# Generate Tests
npm install --dev jest @types/jest doctest-ts ts-jest io-ts-validator maas-schemas-ts fp-ts io-ts io-ts-types
./node_modules/.bin/ts-jest config:init
./node_modules/.bin/doctest-ts --jest `find src -name '*.ts'`
# Run Tests
./node_modules/.bin/jest --testPathPattern --testMatch **/*.doctest.ts --roots src/
# Compile TypeScript Code
./node_modules/.bin/tsc -d --rootDir src src/examples/user.ts --outDir lib/
0.0.26
2 years ago
0.0.24
2 years ago
0.0.25
2 years ago
0.0.26-alpha1
2 years ago
0.0.25-alpha1
2 years ago
0.0.22
2 years ago
0.0.23
2 years ago
0.0.22-alpha1
2 years ago
0.0.21
3 years ago
0.0.20
3 years ago
0.0.20-alpha2
3 years ago
0.0.20-alpha7
3 years ago
0.0.20-alpha3
3 years ago
0.0.20-alpha4
3 years ago
0.0.20-alpha5
3 years ago
0.0.20-alpha6
3 years ago
0.0.20-alpha1
4 years ago
0.0.19
4 years ago
0.0.19-alpha1
4 years ago
0.0.18
4 years ago
0.0.17
4 years ago
0.0.16
4 years ago
0.0.15
5 years ago
0.0.14
5 years ago
0.0.13
5 years ago
0.0.13-alpha6
5 years ago
0.0.13-alpha2
5 years ago
0.0.13-alpha1
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.10-alpha2
5 years ago
0.0.10-alpha1
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.7-alpha1
5 years ago
0.0.6
5 years ago
0.0.6-alpha3
5 years ago
0.0.6-alpha2
5 years ago
0.0.6-alpha1
5 years ago
0.0.5
5 years ago
0.0.5-alpha1
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago