@@ -48,22 +48,10 @@ func (g *Generator) Generate() (*jsonschema.Schema, error) {
4848 }
4949 s .Schema = JsonSchemaURI
5050
51- s .WalkProperties (func (keyPath []* jsonschema.Schema , schema * jsonschema.Schema ) {
52- if ! isDocumented (append (keyPath , schema )) {
53- if schema .Title == "" {
54- return
55- }
56-
57- keyValues := []string {}
58- for _ , k := range append (keyPath , schema ) {
59- if k .Title == "" {
60- continue
61- }
62- keyValues = append (keyValues , k .Title )
63- }
64- g .logger .Warnf ("undocumented value: %s" , strings .Join (keyValues , "." ))
65- }
66- })
51+ s .WalkProperties (
52+ g .warnUndocumentedValue ,
53+ g .warnUntypedValue ,
54+ )
6755
6856 return s , err
6957}
@@ -75,7 +63,9 @@ func (g *Generator) buildScalarNode(key *yaml.Node, value *yaml.Node) (*jsonsche
7563 }
7664
7765 extraNodes := []* yaml.Node {}
78- extraNodes = append (extraNodes , comment .KeyValueNodes ("type" , valueType )... )
66+ if valueType != "null" {
67+ extraNodes = append (extraNodes , comment .KeyValueNodes ("type" , valueType )... )
68+ }
7969 extraNodes = append (extraNodes , comment .KeyValueNodes ("title" , key .Value )... )
8070 extraNodes = append (extraNodes , comment .KeyValueNodes ("default" , value .Value )... )
8171
@@ -218,3 +208,41 @@ func isDocumented(schemaPath []*jsonschema.Schema) bool {
218208
219209 return false
220210}
211+
212+ func (g * Generator ) warnUndocumentedValue (keyPath []* jsonschema.Schema , schema * jsonschema.Schema ) {
213+ if ! isDocumented (append (keyPath , schema )) {
214+ if schema .Title == "" {
215+ return
216+ }
217+
218+ keyValues := []string {}
219+ for _ , k := range append (keyPath , schema ) {
220+ if k .Title == "" {
221+ continue
222+ }
223+ keyValues = append (keyValues , k .Title )
224+ }
225+
226+ g .logger .Warnf ("value is undocumented: %s" , strings .Join (keyValues , "." ))
227+ }
228+ }
229+
230+ func (g * Generator ) warnUntypedValue (keyPath []* jsonschema.Schema , schema * jsonschema.Schema ) {
231+ if schema .Title == "" {
232+ return
233+ }
234+
235+ if schema .Type != "" {
236+ return
237+ }
238+
239+ keyValues := []string {}
240+ for _ , k := range append (keyPath , schema ) {
241+ if k .Title == "" {
242+ continue
243+ }
244+ keyValues = append (keyValues , k .Title )
245+ }
246+
247+ g .logger .Warnf ("value has no type: %s" , strings .Join (keyValues , "." ))
248+ }
0 commit comments