Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fastify/compile-schemas-to-typescript
Compile JSON Schemas to TypeScript interfaces
https://github.com/fastify/compile-schemas-to-typescript
fastify fastify-library
Last synced: 3 months ago
JSON representation
Compile JSON Schemas to TypeScript interfaces
- Host: GitHub
- URL: https://github.com/fastify/compile-schemas-to-typescript
- Owner: fastify
- License: other
- Created: 2019-12-09T18:58:56.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-08T17:04:48.000Z (11 months ago)
- Last Synced: 2024-09-28T11:21:35.703Z (3 months ago)
- Topics: fastify, fastify-library
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 7
- Watchers: 19
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Compile Schemas to TypeScript
This module is a wrapper around the `json-schema-to-typescript` library that enables transformation of directories of schemas instead of individual schemas. If directory support is added to the `json-schema-to-typescript` library this module will be archived.
## CLI
This module works as an CLI. Install as a dependency and call `compile-schemas-to-typescript` from a npm script, or use `npx`
```bash
npx compile-schemas-to-typescript
```## API
`compileSchema(input: string, output: string): Promise`
The method iterates over the contents of the `input` directory and compiles any `.json` files into TypeScript interfaces and stores the generated output into the specified `output` directory.
```javascript
const compileSchemas = require('compile-schemas-to-typescript')(async () => {
try {
await compileSchemas('./schemas', './types')
} catch (err) {
console.error(err)
process.exit(1)
}
})()
```## Contributing
This project is actively maintained by the Fastify team.
Contributions are welcome! Please open an issue and a pull request.
## License
Licensed under [MIT](./LICENSE).