Skip to content

Commit 1dce309

Browse files
authored
Update jsonschema-go library (#10)
1 parent 0de199d commit 1dce309

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.13
55
require (
66
github.com/stretchr/testify v1.5.1
77
github.com/swaggest/assertjson v1.0.0
8-
github.com/swaggest/jsonschema-go v0.3.2
8+
github.com/swaggest/jsonschema-go v0.3.4
99
github.com/swaggest/refl v0.1.3
1010
github.com/swaggest/swgen v0.6.23
1111
gopkg.in/yaml.v2 v2.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ github.com/swaggest/assertjson v1.0.0/go.mod h1:mE5ltBbrB+Ya8Xar5OMITxya76vwLZMo
5454
github.com/swaggest/jsonschema-go v0.2.1 h1:SVg+zXQ46w6ewR7jZDRVbpKKC+V7Y6Xn/teC2pRS2bM=
5555
github.com/swaggest/jsonschema-go v0.2.1/go.mod h1:QFauBdPTrU1UltwocM5FzOWnVjVVtcWkJWG3NlK9sV0=
5656
github.com/swaggest/jsonschema-go v0.2.4/go.mod h1:m4VV88Gbi7lCrt9ckJzigK1rMlEeFjdZUkJr1o5MnDE=
57-
github.com/swaggest/jsonschema-go v0.3.2 h1:k0s1XsyoXyY5hDY1ZHVEig8ROZTqPnEdKK4IhQtlWSw=
58-
github.com/swaggest/jsonschema-go v0.3.2/go.mod h1:TrWgbug4p2ZgcxnHDz+CvYvEtJ5KckL/XOV4mSR6FGw=
57+
github.com/swaggest/jsonschema-go v0.3.4 h1:VoD8ux21OyoSPvRHbWNE1I5SQZ6T6L+WLd2GWS+90X4=
58+
github.com/swaggest/jsonschema-go v0.3.4/go.mod h1:TrWgbug4p2ZgcxnHDz+CvYvEtJ5KckL/XOV4mSR6FGw=
5959
github.com/swaggest/openapi-go v0.1.3/go.mod h1:Zx4ZgJ7XvlFH9wCOHE7u8RAjLfiHAnCHeaD5kUDujVM=
6060
github.com/swaggest/refl v0.1.0 h1:mz3skba8ewcPmxDryM9rETv4fSuAX4GqNxTuDfPyUM0=
6161
github.com/swaggest/refl v0.1.0/go.mod h1:kmYWhxNEvjfRDdMRqpaR/vLULk/SotJs9HFUCIVMK8o=

openapi3/_testdata/openapi_req_array.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"type": "array",
1515
"items": {
1616
"$ref": "#/components/schemas/Openapi3TestGetReq"
17-
}
17+
},
18+
"nullable": true
1819
}
1920
}
2021
}

openapi3/example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func ExampleReflector_SetJSONResponse() {
3131
Items []struct {
3232
Count uint `json:"count"`
3333
Name string `json:"name"`
34-
} `json:"items"`
34+
} `json:"items,omitempty"`
3535
}
3636

3737
type resp struct {
@@ -40,7 +40,7 @@ func ExampleReflector_SetJSONResponse() {
4040
Items []struct {
4141
Count uint `json:"count"`
4242
Name string `json:"name"`
43-
} `json:"items"`
43+
} `json:"items,omitempty"`
4444
UpdatedAt time.Time `json:"updated_at"`
4545
}
4646

openapi3/reflect.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func (r *Reflector) parseParametersIn(o *Operation, input interface{}, in Parame
169169
s := SchemaOrRef{}
170170
s.FromJSONSchema(propertySchema.ToSchemaOrBool())
171171

172+
if s.Schema != nil && s.Schema.Nullable != nil {
173+
s.Schema.Nullable = nil
174+
}
175+
172176
p := Parameter{
173177
Name: name,
174178
In: in,

openapi3/reflect_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ type Resp struct {
4646
Foo string `json:"foo" default:"baz" required:"true" pattern:"\\d+"`
4747
Bar float64 `json:"bar" description:"This is Bar."`
4848
} `json:"info"`
49-
Parent *Resp `json:"parent"`
50-
Map map[string]int64 `json:"map"`
51-
MapOfAnything map[string]interface{} `json:"mapOfAnything"`
52-
ArrayOfAnything []interface{} `json:"arrayOfAnything"`
49+
Parent *Resp `json:"parent,omitempty"`
50+
Map map[string]int64 `json:"map,omitempty"`
51+
MapOfAnything map[string]interface{} `json:"mapOfAnything,omitempty"`
52+
ArrayOfAnything []interface{} `json:"arrayOfAnything,omitempty"`
5353
Whatever interface{} `json:"whatever"`
5454
NullableWhatever *interface{} `json:"nullableWhatever,omitempty"`
55-
RecursiveArray []WeirdResp `json:"recursiveArray"`
56-
RecursiveStructArray []Resp `json:"recursiveStructArray"`
55+
RecursiveArray []WeirdResp `json:"recursiveArray,omitempty"`
56+
RecursiveStructArray []Resp `json:"recursiveStructArray,omitempty"`
5757
CustomType ISOWeek `json:"customType"`
5858
UUID UUID `json:"uuid"`
5959
}

0 commit comments

Comments
 (0)