From 3be4cc4f74ca9045e8069da57b56de942e1ac075 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Thu, 26 Dec 2019 22:54:23 +0530 Subject: [PATCH] print json schema for a sample document the document is of the type map[string]interface{} which is the type when reading a yaml or json file --- .gitignore | 2 ++ go.mod | 5 +++++ go.sum | 7 +++++++ main.go | 17 +++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 .gitignore create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..161075c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +helm-schema-gen \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9ee7f72 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/karuppiah7890/helm-schema-gen + +go 1.13 + +require github.com/karuppiah7890/go-jsonschema-generator v0.0.0-20191226170814-3854335796de diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..52b118a --- /dev/null +++ b/go.sum @@ -0,0 +1,7 @@ +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/karuppiah7890/go-jsonschema-generator v0.0.0-20191226170814-3854335796de h1:xLPxL9cvp8SMJs4UJntWW+avLLeOjZg4j6znMHmOPac= +github.com/karuppiah7890/go-jsonschema-generator v0.0.0-20191226170814-3854335796de/go.mod h1:SltxBi57U2RnGZlEO3kSfuVQ8gdHdgSEcJFQ5zOnqqk= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go new file mode 100644 index 0000000..da00a8c --- /dev/null +++ b/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "github.com/karuppiah7890/go-jsonschema-generator" +) + +func main() { + data := map[string]interface{}{ + "something": map[string]interface{}{ + "okay": "dokey", + }, + } + s := &jsonschema.Document{} + s.ReadDeep(&data) + fmt.Println(s) +}