File tree 2 files changed +36
-29
lines changed
2 files changed +36
-29
lines changed Original file line number Diff line number Diff line change @@ -22,43 +22,50 @@ A basic example:
22
22
package main
23
23
24
24
import (
25
- " fmt"
26
- " github.com/mcuadros/go-jsonschema-generator"
25
+ " fmt"
26
+ " github.com/mcuadros/go-jsonschema-generator"
27
27
)
28
28
29
29
type ExampleBasic struct {
30
- Foo bool ` json:"foo"`
31
- Bar string ` json:",omitempty"`
32
- Qux int8
30
+ Foo bool ` json:"foo"`
31
+ Bar string ` json:",omitempty"`
32
+ Qux int8
33
+ Baz []string
33
34
}
34
35
35
36
func main () {
36
- j := &jsonschema.JSONSchema {}
37
- j.Load (&ExampleBasic{})
38
-
39
- fmt.Println (j)
37
+ s := &jsonschema.Schema {}
38
+ s.Load (&ExampleBasic{})
39
+ fmt.Println (s)
40
40
}
41
-
42
41
```
43
42
44
43
``` json
45
44
{
46
- "type" : " object" ,
47
- "properties" : {
48
- "Bar" : {
49
- "type" : " string"
50
- },
51
- "Qux" : {
52
- "type" : " integer"
45
+ "$schema" : " http://json-schema.org/schema#" ,
46
+ "type" : " object" ,
47
+ "properties" : {
48
+ "Bar" : {
49
+ "type" : " string"
50
+ },
51
+ "Baz" : {
52
+ "type" : " array" ,
53
+ "items" : {
54
+ "type" : " string"
55
+ }
56
+ },
57
+ "Qux" : {
58
+ "type" : " integer"
59
+ },
60
+ "foo" : {
61
+ "type" : " bool"
62
+ }
53
63
},
54
- "foo" : {
55
- "type" : " bool"
56
- }
57
- },
58
- "required" : [
59
- " foo" ,
60
- " Qux"
61
- ]
64
+ "required" : [
65
+ " foo" ,
66
+ " Qux" ,
67
+ " Baz"
68
+ ]
62
69
}
63
70
```
64
71
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ type ExampleBasic struct {
9
9
Foo bool `json:"foo"`
10
10
Bar string `json:",omitempty"`
11
11
Qux int8
12
+ Baz []string
12
13
}
13
14
14
15
func main () {
15
- j := & jsonschema.JSONSchema {}
16
- j .Load (& ExampleBasic {})
17
-
18
- fmt .Println (j )
16
+ s := & jsonschema.Schema {}
17
+ s .Load (& ExampleBasic {})
18
+ fmt .Println (s )
19
19
}
You can’t perform that action at this time.
0 commit comments