Skip to content

Commit

Permalink
Format schema.json on generate (#294)
Browse files Browse the repository at this point in the history
Add rule to format JSON Schema with prettier

---------

Signed-off-by: Alexis Rico <sferadev@gmail.com>
  • Loading branch information
SferaDev committed Mar 1, 2024
1 parent c08ef70 commit 52fb532
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY: generate
generate:
# Format JSON schema
docker run --rm -v $$PWD/schema.json:/mnt/schema.json node:alpine npx prettier /mnt/schema.json --parser json --tab-width 2 --single-quote --trailing-comma all --no-semi --arrow-parens always --print-width 120 > schema.json.tmp
mv schema.json.tmp schema.json

# Generate the types from the JSON schema
docker run --rm -v $$PWD/schema.json:/mnt/schema.json omissis/go-jsonschema:0.14.1 --only-models -p migrations --tags json /mnt/schema.json > pkg/migrations/types.go

Expand Down
24 changes: 12 additions & 12 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@
{
"required": ["up", "down"],
"oneOf": [
{"required": ["check"]},
{"required": ["type"]},
{"required": ["nullable"]},
{"required": ["unique"]},
{"required": ["references"]}
{ "required": ["check"] },
{ "required": ["type"] },
{ "required": ["nullable"] },
{ "required": ["unique"] },
{ "required": ["references"] }
],
"not": {
"required": ["name"]
Expand All @@ -169,13 +169,13 @@
"required": ["name"],
"not": {
"anyOf": [
{ "required": [ "up" ] },
{ "required": [ "down" ] },
{ "required": [ "check" ] },
{ "required": [ "type" ] },
{ "required": [ "nullable" ] },
{ "required": [ "unique" ] },
{ "required": [ "references" ] }
{ "required": ["up"] },
{ "required": ["down"] },
{ "required": ["check"] },
{ "required": ["type"] },
{ "required": ["nullable"] },
{ "required": ["unique"] },
{ "required": ["references"] }
]
}
}
Expand Down

0 comments on commit 52fb532

Please sign in to comment.