Repository: getkin/kin-openapi (go)

Issue:
omitempty in structs producing invalid definitions
There are omitempty tags that end up removing a required field when sending the struct. The `description` field is required as per the Open API 3 specification, and therefore is not a valid definition. 

Could either 
- The omit empty tags be removed from any fields required by the Open API 3 specification
- Or validation added not to allow any required fields, like description, to have an empty string (similar to what has been done for info.Title/info.Version)

This behaviour worked as expected in previous versions up until [this](https://github.com/getkin/kin-openapi/pull/148/files#diff-4da5065edd98a754c28386877c1f2598R28) change was made

```
info:
  title: 'asdf'
  version: '1'
openapi: 3.0.0
paths:
  /test:
    post:
      responses:
        '200':
          description: ''
  /test2:
    post:
      parameters: 
        - name: ''
          in: 'query'
          schema: {}
          required: false
        - name: '1'
          in: 'query'
          content: 
            application/json: {}
          required: false
        - name: '2'
          in: 'query'
          content: 
            application/json: 
              schema: {}
          required: false
      requestBody:
        content: {}
      responses:
        '200':
          description: ''
```

Pull request description:
Amend #204 to fix a edge case
Fixes #185
Amends #204 such that `decode(encode(spec))` does not set empty response descriptions.


Patch:
diff --git a/go.mod b/go.mod
index 9f441f2..2301383 100644
--- a/go.mod
+++ b/go.mod
@@ -1,12 +1,9 @@
 module github.com/getkin/kin-openapi
 
+go 1.14
+
 require (
-	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/ghodss/yaml v1.0.0
-	github.com/kr/pretty v0.1.0 // indirect
-	github.com/stretchr/testify v1.3.0
-	gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
+	github.com/stretchr/testify v1.5.1
 	gopkg.in/yaml.v2 v2.2.8 // indirect
 )
-
-go 1.13
diff --git a/go.sum b/go.sum
index 583c172..22c1b57 100644
--- a/go.sum
+++ b/go.sum
@@ -1,21 +1,13 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
-github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
-github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
-github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
-github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
-github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/jsoninfo/type_info.go b/jsoninfo/type_info.go
index 5d7a4ed..3dbb8d5 100644
--- a/jsoninfo/type_info.go
+++ b/jsoninfo/type_info.go
@@ -60,9 +60,9 @@ func GetTypeInfo(t reflect.Type) *TypeInfo {
 // FieldNames returns all field names
 func (typeInfo *TypeInfo) FieldNames() []string {
 	fields := typeInfo.Fields
-	names := make([]string, len(fields))
-	for i, field := range fields {
-		names[i] = field.JSONName
+	names := make([]string, 0, len(fields))
+	for _, field := range fields {
+		names = append(names, field.JSONName)
 	}
 	return names
 }
diff --git a/openapi2conv/openapi2_conv.go b/openapi2conv/openapi2_conv.go
index 63f9728..274fc8e 100644
--- a/openapi2conv/openapi2_conv.go
+++ b/openapi2conv/openapi2_conv.go
@@ -209,7 +209,7 @@ func ToV3Response(response *openapi2.Response) (*openapi3.ResponseRef, error) {
 		}, nil
 	}
 	result := &openapi3.Response{
-		Description: response.Description,
+		Description: &response.Description,
 	}
 	if schemaRef := response.Schema; schemaRef != nil {
 		result.WithJSONSchemaRef(ToV3SchemaRef(schemaRef))
@@ -594,8 +594,12 @@ func FromV3Response(ref *openapi3.ResponseRef) (*openapi2.Response, error) {
 	if response == nil {
 		return nil, nil
 	}
+	description := ""
+	if desc := response.Description; desc != nil {
+		description = *desc
+	}
 	result := &openapi2.Response{
-		Description: response.Description,
+		Description: description,
 	}
 	if content := response.Content; content != nil {
 		if ct := content["application/json"]; ct != nil {
diff --git a/openapi3/link.go b/openapi3/link.go
index 6815fb4..2c1ec01 100644
--- a/openapi3/link.go
+++ b/openapi3/link.go
@@ -2,6 +2,7 @@ package openapi3
 
 import (
 	"context"
+	"errors"
 	"fmt"
 
 	"github.com/getkin/kin-openapi/jsoninfo"
@@ -28,7 +29,7 @@ func (value *Link) UnmarshalJSON(data []byte) error {
 
 func (value *Link) Validate(c context.Context) error {
 	if value.OperationID == "" && value.OperationRef == "" {
-		return fmt.Errorf("missing operationId or operationRef on link")
+		return errors.New("missing operationId or operationRef on link")
 	}
 	if value.OperationID != "" && value.OperationRef != "" {
 		return fmt.Errorf("operationId '%s' and operationRef '%s' are mutually exclusive", value.OperationID, value.OperationRef)
diff --git a/openapi3/response.go b/openapi3/response.go
index 02e69ca..db83db7 100644
--- a/openapi3/response.go
+++ b/openapi3/response.go
@@ -2,6 +2,7 @@ package openapi3
 
 import (
 	"context"
+	"errors"
 	"strconv"
 
 	"github.com/getkin/kin-openapi/jsoninfo"
@@ -34,7 +35,7 @@ func (responses Responses) Validate(c context.Context) error {
 // Response is specified by OpenAPI/Swagger 3.0 standard.
 type Response struct {
 	ExtensionProps
-	Description string                `json:"description" yaml:"description"`
+	Description *string               `json:"description,omitempty" yaml:"description,omitempty"`
 	Headers     map[string]*HeaderRef `json:"headers,omitempty" yaml:"headers,omitempty"`
 	Content     Content               `json:"content,omitempty" yaml:"content,omitempty"`
 	Links       map[string]*LinkRef   `json:"links,omitempty" yaml:"links,omitempty"`
@@ -45,7 +46,7 @@ func NewResponse() *Response {
 }
 
 func (response *Response) WithDescription(value string) *Response {
-	response.Description = value
+	response.Description = &value
 	return response
 }
 
@@ -73,6 +74,10 @@ func (response *Response) UnmarshalJSON(data []byte) error {
 }
 
 func (response *Response) Validate(c context.Context) error {
+	if response.Description == nil {
+		return errors.New("A short description of the response is required")
+	}
+
 	if content := response.Content; content != nil {
 		if err := content.Validate(c); err != nil {
 			return err
diff --git a/openapi3/schema.go b/openapi3/schema.go
index 87a3c44..f068097 100644
--- a/openapi3/schema.go
+++ b/openapi3/schema.go
@@ -122,9 +122,9 @@ func (schema *Schema) NewRef() *SchemaRef {
 }
 
 func NewOneOfSchema(schemas ...*Schema) *Schema {
-	refs := make([]*SchemaRef, len(schemas))
-	for i, schema := range schemas {
-		refs[i] = &SchemaRef{Value: schema}
+	refs := make([]*SchemaRef, 0, len(schemas))
+	for _, schema := range schemas {
+		refs = append(refs, &SchemaRef{Value: schema})
 	}
 	return &Schema{
 		OneOf: refs,
@@ -132,9 +132,9 @@ func NewOneOfSchema(schemas ...*Schema) *Schema {
 }
 
 func NewAnyOfSchema(schemas ...*Schema) *Schema {
-	refs := make([]*SchemaRef, len(schemas))
-	for i, schema := range schemas {
-		refs[i] = &SchemaRef{Value: schema}
+	refs := make([]*SchemaRef, 0, len(schemas))
+	for _, schema := range schemas {
+		refs = append(refs, &SchemaRef{Value: schema})
 	}
 	return &Schema{
 		AnyOf: refs,
@@ -142,9 +142,9 @@ func NewAnyOfSchema(schemas ...*Schema) *Schema {
 }
 
 func NewAllOfSchema(schemas ...*Schema) *Schema {
-	refs := make([]*SchemaRef, len(schemas))
-	for i, schema := range schemas {
-		refs[i] = &SchemaRef{Value: schema}
+	refs := make([]*SchemaRef, 0, len(schemas))
+	for _, schema := range schemas {
+		refs = append(refs, &SchemaRef{Value: schema})
 	}
 	return &Schema{
 		AllOf: refs,
@@ -439,7 +439,7 @@ func (schema *Schema) IsEmpty() bool {
 }
 
 func (schema *Schema) Validate(c context.Context) error {
-	return schema.validate(c, make([]*Schema, 2))
+	return schema.validate(c, []*Schema{})
 }
 
 func (schema *Schema) validate(c context.Context, stack []*Schema) (err error) {
@@ -1158,9 +1158,9 @@ func markSchemaErrorIndex(err error, index int) error {
 
 func (err *SchemaError) JSONPointer() []string {
 	reversePath := err.reversePath
-	path := make([]string, len(reversePath))
-	for i := range path {
-		path[i] = reversePath[len(path)-1-i]
+	path := append([]string(nil), reversePath...)
+	for left, right := 0, len(path)-1; left < right; left, right = left+1, right-1 {
+		path[left], path[right] = path[right], path[left]
 	}
 	return path
 }
diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go
index f65b142..3b1de11 100644
--- a/openapi3filter/req_resp_decoder.go
+++ b/openapi3filter/req_resp_decoder.go
@@ -104,16 +104,21 @@ func invalidSerializationMethodErr(sm *openapi3.SerializationMethod) error {
 func decodeContentParameter(param *openapi3.Parameter, input *RequestValidationInput) (
 	value interface{}, schema *openapi3.Schema, err error) {
 
-	paramValues := make([]string, 1)
+	var paramValues []string
 	var found bool
 	switch param.In {
 	case openapi3.ParameterInPath:
-		paramValues[0], found = input.PathParams[param.Name]
+		var paramValue string
+		if paramValue, found = input.PathParams[param.Name]; found {
+			paramValues = []string{paramValue}
+		}
 	case openapi3.ParameterInQuery:
 		paramValues, found = input.GetQueryParams()[param.Name]
 	case openapi3.ParameterInHeader:
-		paramValues[0] = input.Request.Header.Get(http.CanonicalHeaderKey(param.Name))
-		found = paramValues[0] != ""
+		if paramValue := input.Request.Header.Get(http.CanonicalHeaderKey(param.Name)); paramValue != "" {
+			paramValues = []string{paramValue}
+			found = true
+		}
 	case openapi3.ParameterInCookie:
 		var cookie *http.Cookie
 		if cookie, err = input.Request.Cookie(param.Name); err == http.ErrNoCookie {
@@ -121,7 +126,7 @@ func decodeContentParameter(param *openapi3.Parameter, input *RequestValidationI
 		} else if err != nil {
 			return
 		} else {
-			paramValues[0] = cookie.Value
+			paramValues = []string{cookie.Value}
 			found = true
 		}
 	default:
@@ -178,12 +183,14 @@ func defaultContentParameterDecoder(param *openapi3.Parameter, values []string)
 			return
 		}
 	} else {
-		outArray := make([]interface{}, len(values))
-		for i, v := range values {
-			if err = json.Unmarshal([]byte(v), &outArray[i]); err != nil {
+		outArray := make([]interface{}, 0, len(values))
+		for _, v := range values {
+			var item interface{}
+			if err = json.Unmarshal([]byte(v), &item); err != nil {
 				err = fmt.Errorf("error unmarshaling parameter '%s' as json", param.Name)
 				return
 			}
+			outArray = append(outArray, item)
 		}
 		outValue = outArray
 	}
diff --git a/openapi3filter/validate_request.go b/openapi3filter/validate_request.go
index 4f4b15b..7fcac59 100644
--- a/openapi3filter/validate_request.go
+++ b/openapi3filter/validate_request.go
@@ -214,7 +214,7 @@ func ValidateSecurityRequirements(c context.Context, input *RequestValidationInp
 	}
 
 	var wg sync.WaitGroup
-	errs := make([]error, len(srs))
+	errs := make([]error /*zeros,here*/, len(srs))
 
 	// For each alternative security requirement
 	for i, securityRequirement := range srs {


Test patch:
diff --git a/openapi3/operation_test.go b/openapi3/operation_test.go
index 43a5dfe..22f325e 100644
--- a/openapi3/operation_test.go
+++ b/openapi3/operation_test.go
@@ -40,7 +40,7 @@ func operationWithoutResponses() *Operation {
 
 func operationWithResponses() *Operation {
 	initOperation()
-	operation.AddResponse(200, NewResponse())
+	operation.AddResponse(200, NewResponse().WithDescription("some response"))
 	return operation
 }
 
diff --git a/openapi3/schema_test.go b/openapi3/schema_test.go
index 3c16101..e82aba2 100644
--- a/openapi3/schema_test.go
+++ b/openapi3/schema_test.go
@@ -319,16 +319,16 @@ var schemaExamples = []schemaExample{
 		AllValid: []interface{}{
 			"",
 			base64.StdEncoding.EncodeToString(func() []byte {
-				data := make([]byte, 1024)
-				for i := range data {
-					data[i] = byte(i)
+				data := make([]byte, 0, 1024)
+				for i := 0; i < cap(data); i++ {
+					data = append(data, byte(i))
 				}
 				return data
 			}()),
 			base64.URLEncoding.EncodeToString(func() []byte {
-				data := make([]byte, 1024)
-				for i := range data {
-					data[i] = byte(i)
+				data := make([]byte, 0, 1024)
+				for i := 0; i < cap(data); i++ {
+					data = append(data, byte(i))
 				}
 				return data
 			}()),
diff --git a/openapi3/swagger_loader_empty_response_description_test.go b/openapi3/swagger_loader_empty_response_description_test.go
new file mode 100644
index 0000000..5199ac1
--- /dev/null
+++ b/openapi3/swagger_loader_empty_response_description_test.go
@@ -0,0 +1,84 @@
+package openapi3_test
+
+import (
+	"encoding/json"
+	"strings"
+	"testing"
+
+	"github.com/getkin/kin-openapi/openapi3"
+	"github.com/stretchr/testify/require"
+)
+
+func TestJSONSpecResponseDescriptionEmptiness(t *testing.T) {
+	const spec = `
+{
+  "info": {
+    "description": "A sample API to illustrate OpenAPI concepts",
+    "title": "Sample API",
+    "version": "1.0.0"
+  },
+  "openapi": "3.0.0",
+  "paths": {
+    "/path1": {
+      "get": {
+        "responses": {
+          "200": {
+            "description": ""
+          }
+        }
+      }
+    }
+  }
+}
+`
+
+	{
+		spec := []byte(spec)
+		loader := openapi3.NewSwaggerLoader()
+		doc, err := loader.LoadSwaggerFromData(spec)
+		require.NoError(t, err)
+		got := doc.Paths["/path1"].Get.Responses["200"].Value.Description
+		expected := ""
+		require.Equal(t, &expected, got)
+		t.Log("Empty description provided: valid spec")
+		err = doc.Validate(loader.Context)
+		require.NoError(t, err)
+	}
+
+	{
+		spec := []byte(strings.Replace(spec, `"description": ""`, `"description": "My response"`, 1))
+		loader := openapi3.NewSwaggerLoader()
+		doc, err := loader.LoadSwaggerFromData(spec)
+		require.NoError(t, err)
+		got := doc.Paths["/path1"].Get.Responses["200"].Value.Description
+		expected := "My response"
+		require.Equal(t, &expected, got)
+		t.Log("Non-empty description provided: valid spec")
+		err = doc.Validate(loader.Context)
+		require.NoError(t, err)
+	}
+
+	noDescriptionIsInvalid := func(data []byte) *openapi3.Swagger {
+		loader := openapi3.NewSwaggerLoader()
+		doc, err := loader.LoadSwaggerFromData(data)
+		require.NoError(t, err)
+		got := doc.Paths["/path1"].Get.Responses["200"].Value.Description
+		require.Nil(t, got)
+		t.Log("No description provided: invalid spec")
+		err = doc.Validate(loader.Context)
+		require.Error(t, err)
+		return doc
+	}
+
+	var docWithNoResponseDescription *openapi3.Swagger
+	{
+		spec := []byte(strings.Replace(spec, `"description": ""`, ``, 1))
+		docWithNoResponseDescription = noDescriptionIsInvalid(spec)
+	}
+
+	str, err := json.Marshal(docWithNoResponseDescription)
+	require.NoError(t, err)
+	require.NotEmpty(t, str)
+	t.Log("Reserialization does not set description")
+	_ = noDescriptionIsInvalid(str)
+}
diff --git a/openapi3/swagger_loader_relative_refs_test.go b/openapi3/swagger_loader_relative_refs_test.go
index 0e4c19d..5ad7585 100644
--- a/openapi3/swagger_loader_relative_refs_test.go
+++ b/openapi3/swagger_loader_relative_refs_test.go
@@ -36,8 +36,8 @@ var refTestDataEntries = []refTestDataEntry{
 		name:            "ResponseRef",
 		contentTemplate: externalResponseRefTemplate,
 		testFunc: func(t *testing.T, swagger *openapi3.Swagger) {
-			require.NotNil(t, swagger.Components.Responses["TestResponse"].Value.Description)
-			require.Equal(t, "description", swagger.Components.Responses["TestResponse"].Value.Description)
+			desc := "description"
+			require.Equal(t, &desc, swagger.Components.Responses["TestResponse"].Value.Description)
 		},
 	},
 	{
@@ -108,7 +108,8 @@ var refTestDataEntries = []refTestDataEntry{
 		contentTemplate: externalPathOperationResponseRefTemplate,
 		testFunc: func(t *testing.T, swagger *openapi3.Swagger) {
 			require.NotNil(t, swagger.Paths["/test"].Post.Responses["default"].Value)
-			require.Equal(t, "description", swagger.Paths["/test"].Post.Responses["default"].Value.Description)
+			desc := "description"
+			require.Equal(t, &desc, swagger.Paths["/test"].Post.Responses["default"].Value.Description)
 		},
 	},
 	{
@@ -152,7 +153,8 @@ var refTestDataEntries = []refTestDataEntry{
 		contentTemplate: externalPathOperationResponseExampleRefTemplate,
 		testFunc: func(t *testing.T, swagger *openapi3.Swagger) {
 			require.NotNil(t, swagger.Paths["/test"].Post.Responses["default"].Value)
-			require.Equal(t, "testdescription", swagger.Paths["/test"].Post.Responses["default"].Value.Description)
+			desc := "testdescription"
+			require.Equal(t, &desc, swagger.Paths["/test"].Post.Responses["default"].Value.Description)
 			require.Equal(t, "description", swagger.Paths["/test"].Post.Responses["default"].Value.Content["application/json"].Examples["application/json"].Value.Description)
 		},
 	},
@@ -161,7 +163,8 @@ var refTestDataEntries = []refTestDataEntry{
 		contentTemplate: externalPathOperationResponseSchemaRefTemplate,
 		testFunc: func(t *testing.T, swagger *openapi3.Swagger) {
 			require.NotNil(t, swagger.Paths["/test"].Post.Responses["default"].Value)
-			require.Equal(t, "testdescription", swagger.Paths["/test"].Post.Responses["default"].Value.Description)
+			desc := "testdescription"
+			require.Equal(t, &desc, swagger.Paths["/test"].Post.Responses["default"].Value.Description)
 			require.Equal(t, "string", swagger.Paths["/test"].Post.Responses["default"].Value.Content["application/json"].Schema.Value.Type)
 		},
 	},
@@ -731,8 +734,8 @@ var relativeDocRefsTestDataEntries = []refTestDataEntry{
 		name:            "ResponseRef",
 		contentTemplate: relativeResponseDocsRefTemplate,
 		testFunc: func(t *testing.T, swagger *openapi3.Swagger) {
-			require.NotNil(t, swagger.Components.Responses["TestResponse"].Value.Description)
-			require.Equal(t, "description", swagger.Components.Responses["TestResponse"].Value.Description)
+			desc := "description"
+			require.Equal(t, &desc, swagger.Components.Responses["TestResponse"].Value.Description)
 		},
 	},
 	{
diff --git a/openapi3/swagger_loader_test.go b/openapi3/swagger_loader_test.go
index 62b0c48..4d2cb42 100644
--- a/openapi3/swagger_loader_test.go
+++ b/openapi3/swagger_loader_test.go
@@ -62,7 +62,8 @@ paths:
 	require.Equal(t, 2, len(doc.Components.Schemas))
 	require.Equal(t, 1, len(doc.Paths))
 	def := doc.Paths["/items"].Put.Responses.Default().Value
-	require.Equal(t, "unexpected error", def.Description)
+	desc := "unexpected error"
+	require.Equal(t, &desc, def.Description)
 	err = doc.Validate(loader.Context)
 	require.NoError(t, err)
 }
@@ -332,7 +333,8 @@ func TestLoadFileWithExternalSchemaRefSingleComponent(t *testing.T) {
 	require.NoError(t, err)
 
 	require.NotNil(t, swagger.Components.Responses["SomeResponse"])
-	require.Equal(t, "this is a single response definition", swagger.Components.Responses["SomeResponse"].Value.Description)
+	desc := "this is a single response definition"
+	require.Equal(t, &desc, swagger.Components.Responses["SomeResponse"].Value.Description)
 }
 
 func TestLoadRequestResponseHeaderRef(t *testing.T) {
diff --git a/openapi3/swagger_test.go b/openapi3/swagger_test.go
index 673e5f0..d4c4339 100644
--- a/openapi3/swagger_test.go
+++ b/openapi3/swagger_test.go
@@ -250,8 +250,9 @@ func spec() *openapi3.Swagger {
 	requestBody := &openapi3.RequestBody{
 		Description: "Some request body",
 	}
+	responseDescription := "Some response"
 	response := &openapi3.Response{
-		Description: "Some response",
+		Description: &responseDescription,
 	}
 	schema := &openapi3.Schema{
 		Description: "Some schema",