json-schema-artifact
v1.1.1
Published
JSON Schema bundler
Downloads
9
Readme
Installation
npm install --save-dev json-schema-artifact
Usage
- Create a file named
json-schema-artifact.json
in the workspace root.
This configuration implies monitoring all files in the
src
directory and triggering a rebuild when changes occur. The build process utilizessrc/example.json
as input and producesdist/example.json
as output.If you have any internationalization (i18n) requirements, you can configure the locale field to specify the language file(in JSON format) to be used. In your source files, define keys in the format of t(`key`). If the corresponding key is not found in the language file, the key itself will be used as a fallback. This process will generate additional output files based on the configured locales.
You can find an example here.
{
"$schema": "node_modules/json-schema-artifact/schema/json-schema-artifact.json",
"watch": [
{
"dir": "src",
"recursive": true
}
],
"build": {
"target": [
{
"input": "src/example.json",
"output": "dist/example.json"
// "locale": {
// "ru": "test/locales/ru.json",
// "fa": "test/locales/fa.json"
// }
}
],
"optimize": {
"format": "minify", // or pretty
"refsDerefer": true
}
}
}
- Start coding your JSON Schema with
watch
on.
npx json-schema-artifact --watch
You can include the following similar configurations in the .vscode/settings.json
file for validation.
"json.schemas": [
{
"url": "./dist/example.json",
"fileMatch": ["test/example-test-data.json"]
}
],
- Bundle JSON Schema and check the output.
npx json-schema-artifact