https://github.com/emptyless/jsonschema-transform
jsonschema-transform is a CLI utility that can transform JSON Schema into D2. This can be useful to visualize a large set of JSON Schema's that are interconnected (and possibly have remote references)
https://github.com/emptyless/jsonschema-transform
d2 jsonschema
Last synced: 9 months ago
JSON representation
jsonschema-transform is a CLI utility that can transform JSON Schema into D2. This can be useful to visualize a large set of JSON Schema's that are interconnected (and possibly have remote references)
- Host: GitHub
- URL: https://github.com/emptyless/jsonschema-transform
- Owner: Emptyless
- License: mit
- Created: 2025-02-11T10:41:23.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-27T07:55:09.000Z (9 months ago)
- Last Synced: 2025-03-27T08:39:15.080Z (9 months ago)
- Topics: d2, jsonschema
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON-Schema Transform
_This CLI tool is under active development and must be considered alpha. It's API may be changed in a breaking way until a 1.0 version is released. Submit issues to the Github issue tracker if found._
`jsonschema-transform` is a CLI utility that can transform [JSON Schema](https://json-schema.org) into [D2](https://d2lang.com). This can be useful to visualize a large set of JSON Schema's that are interconnected (and possibly have remote references).
### Quickstart
With default arguments, running `jsonschema-transform d2` to create the `d2` representation of the `testdata` directory:
```
$ jsonschema-transform d2 --globs ./testdata/*.json
```
A new output file named `diagram.d2` is created in the current working directory. To create an SVG, change the output to a SVG filetype:
```
$ jsonschema-transform d2 --globs ./testdata/*.json --output diagram.svg
```

### Installation
```
go install github.com/Emptyless/jsonschema-transform
```
Also make sure that `d2` is installed:
```
brew install d2
```
### Usage
- `--globs`: to match containing JSON Schema documents, e.g. `*/*.json` or `./testdata/pet.json`
- `--base-uri`: to use for fetching relative $refs, including `file://` based $refs
- `--overwrite`: allow overwrite of output file if the file exists already
- `--output`: name of the output file (extension must be either 'svg' or 'd2')
- `-v` (or `-vv`, `-vvv`): sets the verbosity
- `-q`: quiet (opposite of verbosity)
### TODO's
- [x] get basic structure of CLI working
- [ ] test against more complex JSON Schema's
- [ ] generate markdown (MD) files from the JSON schemas with clickable links
### Mentions
- [kaptinlin/jsonschema](github.com/kaptinlin/jsonschema): a Go JSON Schema library