1.12.0 • Published 4 years ago
@etclabscore/json-schema-to-types v1.12.0
JSON-Schema-To-Types
This is a JSON-Schema transpiler. It converts a JSON Schema into types for various strongly typed languages.
Features:
- Supports the following languages:
- Typescript
- Rust
- Go
- Python
- minimal external dependencies
- circular JSON structure handling
- Supports merging multiple JSONSchema into one set of types
- Generates titles for schemas that are missing them
- Run in browser / node
Installing
npm install --save @etclabscore/json-schema-to-types
Usage
const schema = {
title: "testerooskies",
type: "object",
properties: {
fooThing: { title: "foo", type: "string" },
barThing: { title: "bar", type: "number" },
},
};
const transpiler = new JsonSchemaToTypes(schema);
console.log(transpiler.toRust())
/** outputs:
"#[derive(Serialize, Deserialize)]
pub struct testerooskies {
pub(crate) fooThing: foo,
pub(crate) barThing: bar,
**
pub type foo = String;
pub type bar = String;"
**/
console.log(transpiler.toTypescript());
/**outputs
"export interface testerooskies {
fooThing: foo;
barThing: bar;
}
export type foo = string;
export type bar = string;"
**/
To add a new integration test case
npm run test:generate
Contributing
How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.
1.12.0
4 years ago
1.11.2
5 years ago
1.11.1
5 years ago
1.11.0
5 years ago
1.10.1
5 years ago
1.9.0
5 years ago
1.10.0
5 years ago
1.8.0
5 years ago
1.7.2
5 years ago
1.7.1
5 years ago
1.7.0
5 years ago
1.6.3
5 years ago
1.6.2
5 years ago
1.6.1
5 years ago
1.6.0
5 years ago
1.5.0
5 years ago
1.4.1
5 years ago
1.4.0
5 years ago
1.3.0
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago