Skip to content

Commit

Permalink
fix: assignment to entry in nil map with @Header all #1082 (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubogdan committed Dec 23, 2021
1 parent 9d81576 commit 54c9ff9
Show file tree
Hide file tree
Showing 4 changed files with 414 additions and 498 deletions.
20 changes: 7 additions & 13 deletions operation.go
Expand Up @@ -61,7 +61,13 @@ func NewOperation(parser *Parser, options ...func(*Operation)) *Operation {
parser: parser,
RouterProperties: []RouteProperties{},
Operation: spec.Operation{
OperationProps: spec.OperationProps{},
OperationProps: spec.OperationProps{
Responses: &spec.Responses{
ResponsesProps: spec.ResponsesProps{
StatusCodeResponses: make(map[int]spec.Response),
},
},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{},
},
Expand Down Expand Up @@ -984,10 +990,6 @@ func (operation *Operation) ParseEmptyResponseOnly(commentLine string) error {

// DefaultResponse return the default response member pointer.
func (operation *Operation) DefaultResponse() *spec.Response {
if operation.Responses == nil {
operation.Responses = &spec.Responses{}
}

if operation.Responses.Default == nil {
operation.Responses.Default = spec.NewResponse()
}
Expand All @@ -997,14 +999,6 @@ func (operation *Operation) DefaultResponse() *spec.Response {

// AddResponse add a response for a code.
func (operation *Operation) AddResponse(code int, response *spec.Response) {
if operation.Responses == nil {
operation.Responses = &spec.Responses{
ResponsesProps: spec.ResponsesProps{
StatusCodeResponses: make(map[int]spec.Response),
},
}
}

operation.Responses.StatusCodeResponses[code] = *response
}

Expand Down

0 comments on commit 54c9ff9

Please sign in to comment.