Repository: swaggest/openapi-go
Pull request #10 (2020-06-13 23:45:11)

Update jsonschema-go library

codecov[bot]: # [Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=h1) Report
> Merging [#10](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=desc) into [master](https://codecov.io/gh/swaggest/openapi-go/commit/0de199d5ff25591738abe087c171c9a97118f5d0&el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/swaggest/openapi-go/pull/10/graphs/tree.svg?width=650&height=150&src=pr&token=3uETjeijpQ)](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
+ Coverage   11.99%   12.03%   +0.04%     
==========================================
  Files           5        5              
  Lines        4085     4087       +2     
==========================================
+ Hits          490      492       +2     
  Misses       3538     3538              
  Partials       57       57              
```


| [Impacted Files](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [openapi3/reflect.go](https://codecov.io/gh/swaggest/openapi-go/pull/10/diff?src=pr&el=tree#diff-b3BlbmFwaTMvcmVmbGVjdC5nbw==) | `84.21% <100.00%> (+0.18%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=footer). Last update [0de199d...e27745a](https://codecov.io/gh/swaggest/openapi-go/pull/10?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/go.mod b/go.mod
index cefa517..ea91b30 100644
--- a/go.mod
+++ b/go.mod
@@ -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
diff --git a/go.sum b/go.sum
index b6c1254..1f24f90 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
diff --git a/openapi3/reflect.go b/openapi3/reflect.go
index 417343d..303abc5 100644
--- a/openapi3/reflect.go
+++ b/openapi3/reflect.go
@@ -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,


Test patch:
diff --git a/openapi3/_testdata/openapi_req_array.json b/openapi3/_testdata/openapi_req_array.json
index cef15c8..147a637 100644
--- a/openapi3/_testdata/openapi_req_array.json
+++ b/openapi3/_testdata/openapi_req_array.json
@@ -14,7 +14,8 @@
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Openapi3TestGetReq"
-        }
+        },
+        "nullable": true
        }
       }
      }
diff --git a/openapi3/example_test.go b/openapi3/example_test.go
index a349fb2..ee462b4 100644
--- a/openapi3/example_test.go
+++ b/openapi3/example_test.go
@@ -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 {
@@ -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"`
 	}
 
diff --git a/openapi3/reflect_test.go b/openapi3/reflect_test.go
index 284aab6..b9bfac8 100644
--- a/openapi3/reflect_test.go
+++ b/openapi3/reflect_test.go
@@ -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"`
 }