spring-data-rest-json-schema-to-typescript-definitions
v0.1.7
Published
npm package that allows you to generate TypeScript definitions from JSON Schema metadata supplied by Spring Data REST endpoints.
Downloads
17
Maintainers
Readme
spring-data-rest-json-schema-to-typescript-definitions
npm package that allows you to generate TypeScript declaration files from JSON Schema metadata supplied by Spring Data REST endpoints.
Getting Started
Installing
npm install spring-data-rest-json-schema-to-typescript-definitions --save-dev
Usage
Add a script named generate-model to your project's package.json, e.g.:
{
...
"scripts": {
...
"generate-model": "node node_modules/spring-data-rest-json-schema-to-typescript-definitions/dist/index.js http://localhost:8080 ./src/app/generated-model"
...
},
...
}
The main index.js takes two arguments:
- The root URL of the API (http://localhost:8080 in the example above; the script automatically appends the /profile part to the URL) generated by Spring Data REST (see https://docs.spring.io/spring-data/rest/docs/current/reference/html/#metadata.json-schema for more information).
- The directory to which the TypeScript declaration files will be written (./src/app/generated-model in the example above).
Now you can generate TypeScript declaration files from your Spring Data REST endpoints by using this command from your project's root directory:
npm run generate-model
Built With
Authors
License
Acknowledgements
Thanks to Boris Cherny whose json-schema-to-typescript package I could draw upon for creating this package.