Skip to content

grimmerk/ts-json-schema

Repository files navigation

TS-JSON-SCHEMA

Prerequisite

  1. Install yarn. https://yarnpkg.com/zh-Hans/
  2. Install TypeScript globally [recommended way]. yarn add global typescript
  3. 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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy