Skip to content

Commit

Permalink
Update jsonschema-go library (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Jun 13, 2020
1 parent 0de199d commit 1dce309
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/stretchr/testify v1.5.1
github.com/swaggest/assertjson v1.0.0
github.com/swaggest/jsonschema-go v0.3.2
github.com/swaggest/jsonschema-go v0.3.4
github.com/swaggest/refl v0.1.3
github.com/swaggest/swgen v0.6.23
gopkg.in/yaml.v2 v2.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/swaggest/assertjson v1.0.0/go.mod h1:mE5ltBbrB+Ya8Xar5OMITxya76vwLZMo
github.com/swaggest/jsonschema-go v0.2.1 h1:SVg+zXQ46w6ewR7jZDRVbpKKC+V7Y6Xn/teC2pRS2bM=
github.com/swaggest/jsonschema-go v0.2.1/go.mod h1:QFauBdPTrU1UltwocM5FzOWnVjVVtcWkJWG3NlK9sV0=
github.com/swaggest/jsonschema-go v0.2.4/go.mod h1:m4VV88Gbi7lCrt9ckJzigK1rMlEeFjdZUkJr1o5MnDE=
github.com/swaggest/jsonschema-go v0.3.2 h1:k0s1XsyoXyY5hDY1ZHVEig8ROZTqPnEdKK4IhQtlWSw=
github.com/swaggest/jsonschema-go v0.3.2/go.mod h1:TrWgbug4p2ZgcxnHDz+CvYvEtJ5KckL/XOV4mSR6FGw=
github.com/swaggest/jsonschema-go v0.3.4 h1:VoD8ux21OyoSPvRHbWNE1I5SQZ6T6L+WLd2GWS+90X4=
github.com/swaggest/jsonschema-go v0.3.4/go.mod h1:TrWgbug4p2ZgcxnHDz+CvYvEtJ5KckL/XOV4mSR6FGw=
github.com/swaggest/openapi-go v0.1.3/go.mod h1:Zx4ZgJ7XvlFH9wCOHE7u8RAjLfiHAnCHeaD5kUDujVM=
github.com/swaggest/refl v0.1.0 h1:mz3skba8ewcPmxDryM9rETv4fSuAX4GqNxTuDfPyUM0=
github.com/swaggest/refl v0.1.0/go.mod h1:kmYWhxNEvjfRDdMRqpaR/vLULk/SotJs9HFUCIVMK8o=
Expand Down
3 changes: 2 additions & 1 deletion openapi3/_testdata/openapi_req_array.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/Openapi3TestGetReq"
}
},
"nullable": true
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions openapi3/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ExampleReflector_SetJSONResponse() {
Items []struct {
Count uint `json:"count"`
Name string `json:"name"`
} `json:"items"`
} `json:"items,omitempty"`
}

type resp struct {
Expand All @@ -40,7 +40,7 @@ func ExampleReflector_SetJSONResponse() {
Items []struct {
Count uint `json:"count"`
Name string `json:"name"`
} `json:"items"`
} `json:"items,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}

Expand Down
4 changes: 4 additions & 0 deletions openapi3/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func (r *Reflector) parseParametersIn(o *Operation, input interface{}, in Parame
s := SchemaOrRef{}
s.FromJSONSchema(propertySchema.ToSchemaOrBool())

if s.Schema != nil && s.Schema.Nullable != nil {
s.Schema.Nullable = nil
}

p := Parameter{
Name: name,
In: in,
Expand Down
12 changes: 6 additions & 6 deletions openapi3/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ type Resp struct {
Foo string `json:"foo" default:"baz" required:"true" pattern:"\\d+"`
Bar float64 `json:"bar" description:"This is Bar."`
} `json:"info"`
Parent *Resp `json:"parent"`
Map map[string]int64 `json:"map"`
MapOfAnything map[string]interface{} `json:"mapOfAnything"`
ArrayOfAnything []interface{} `json:"arrayOfAnything"`
Parent *Resp `json:"parent,omitempty"`
Map map[string]int64 `json:"map,omitempty"`
MapOfAnything map[string]interface{} `json:"mapOfAnything,omitempty"`
ArrayOfAnything []interface{} `json:"arrayOfAnything,omitempty"`
Whatever interface{} `json:"whatever"`
NullableWhatever *interface{} `json:"nullableWhatever,omitempty"`
RecursiveArray []WeirdResp `json:"recursiveArray"`
RecursiveStructArray []Resp `json:"recursiveStructArray"`
RecursiveArray []WeirdResp `json:"recursiveArray,omitempty"`
RecursiveStructArray []Resp `json:"recursiveStructArray,omitempty"`
CustomType ISOWeek `json:"customType"`
UUID UUID `json:"uuid"`
}
Expand Down

0 comments on commit 1dce309

Please sign in to comment.