| 136 | } |
| 137 | |
| 138 | func (e *Encoder) operationToMap(op *model.Operation) map[string]any { |
| 139 | m := make(map[string]any) |
| 140 | |
| 141 | if len(op.Tags) > 0 { |
| 142 | m["tags"] = op.Tags |
| 143 | } |
| 144 | if op.OperationId != "" { |
| 145 | m["operationId"] = op.OperationId |
| 146 | } |
| 147 | if op.RequestBody != nil { |
| 148 | m["requestBody"] = e.requestBodyToMap(op.RequestBody) |
| 149 | } |
| 150 | if len(op.Responses) > 0 { |
| 151 | resps := make(map[string]any) |
| 152 | for code, resp := range op.Responses { |
| 153 | resps[code] = e.responseToMap(resp) |
| 154 | } |
| 155 | m["responses"] = resps |
| 156 | } |
| 157 | |
| 158 | return m |
| 159 | } |
| 160 | |
| 161 | func (e *Encoder) requestBodyToMap(r *model.RequestBody) map[string]any { |
| 162 | m := make(map[string]any) |