npm package that allows you to generate TypeScript definitions from JSON Schema metadata supplied by Spring Data REST endpoints.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.gitignore
.npmignore
LICENSE
README.md
_config.yml
package-lock.json
package.json
tsconfig.json

README.md

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:

  1. 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).
  2. 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

Apache License 2.0

Acknowledgements

Thanks to Boris Cherny whose json-schema-to-typescript package I could draw upon for creating this package.