Skip to content

Commit

Permalink
fix: Add JSON Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jan 25, 2025
1 parent 29882d3 commit 1880e62
Show file tree
Hide file tree
Showing 3 changed files with 488 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TBLS ?= ./tbls

default: test

ci: depsdev build db test testdoc testdoc_hide_auto_increment test_too_many_tables test_json test_ext_subcommand doc
ci: depsdev build db test testdoc testdoc_hide_auto_increment test_too_many_tables test_json test_ext_subcommand test_jsonschema doc

ci_windows: depsdev build db_sqlite testdoc_sqlite

Expand Down Expand Up @@ -147,6 +147,12 @@ test_ext_subcommand: build
env PATH="${PWD}/testdata/bin:${PATH}" TBLS_DSN=pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable $(TBLS) echo | grep 'TBLS_DSN=pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable' > /dev/null
echo hello | env PATH="${PWD}/testdata/bin:${PATH}" $(TBLS) echo -c ./testdata/ext_subcommand_tbls.yml | grep 'STDIN=hello' > /dev/null

test_jsonschema:
cd scripts/jsonschema && go run main.go | diff -u ../../spec/schema_schema.json -

generate_jsonschema:
cd scripts/jsonschema && go run main.go > ../../spec/schema_schema.json

generate_test_json: build
sqlite3 $(PWD)/filter_tables.sqlite3 < testdata/ddl/filter_tables.sql
$(TBLS) out sq://$(PWD)/filter_tables.sqlite3 -t json > testdata/filter_tables.json
Expand Down
2 changes: 2 additions & 0 deletions scripts/jsonschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/k1LoW/tbls/schema"
)

// Generate JSON Schema of schema.json.
func main() {
if err := _main(); err != nil {
fmt.Println(err)
Expand All @@ -31,5 +32,6 @@ func _main() error {
return err
}
fmt.Println(string(b))
fmt.Println()
return nil
}
Loading

0 comments on commit 1880e62

Please sign in to comment.