Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grimmer0125/ts-json-schema
Use https://github.com/YousefED/typescript-json-schema 1. TypeScript -> Json Schema and 2. use ajv (master branch) / python jsonschema to import schema and invalidate json data.
https://github.com/grimmer0125/ts-json-schema
ajv typescript typescript-json-schema
Last synced: 7 days ago
JSON representation
Use https://github.com/YousefED/typescript-json-schema 1. TypeScript -> Json Schema and 2. use ajv (master branch) / python jsonschema to import schema and invalidate json data.
- Host: GitHub
- URL: https://github.com/grimmer0125/ts-json-schema
- Owner: grimmer0125
- Created: 2019-02-23T14:23:39.000Z (almost 6 years ago)
- Default Branch: bdd
- Last Pushed: 2023-07-11T20:22:08.000Z (over 1 year ago)
- Last Synced: 2024-12-22T00:22:50.495Z (2 months ago)
- Topics: ajv, typescript, typescript-json-schema
- Language: TypeScript
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## TS-JSON-SCHEMA
## Prerequisite
1. Install yarn. https://yarnpkg.com/zh-Hans/
1. ~Install TypeScript globally [recommended way]. `yarn add global typescript`~
1. Execute `yarn` or `yarn install` in project root.## In command line to use typescript-json-schema lib to generate json schema
`yarn run typescript-json-schema myString.ts MyString`
result in stdout, add `-o json.schema` to redirect to a file
## Test example.ts (master branch) to generate json scheman, and use AJV to validate (in js/ts), interface: myString.ts
1. Compile TypeScript to JavaScript, `yarn run build example.ts`
2. Test, `node example.js`, result in json.schema## Test example.ts (bdd branch) to generate json schema, and use python to validate, interface: myObject.ts
1. `yarn run build example.ts`
2. `node example.js`
3. `pip install jsonschema`, it not installed
4. `python test.py` to validate