setRequestBodyFromBody configures op.RequestBody from the Body field.
(op *Operation, registry Registry, fBody reflect.StructField, inputType reflect.Type)
| 1392 | |
| 1393 | // setRequestBodyFromBody configures op.RequestBody from the Body field. |
| 1394 | func setRequestBodyFromBody(op *Operation, registry Registry, fBody reflect.StructField, inputType reflect.Type) { |
| 1395 | if fBody.Tag.Get("required") == "true" || (fBody.Type.Kind() != reflect.Pointer && fBody.Type.Kind() != reflect.Interface) { |
| 1396 | setRequestBodyRequired(op.RequestBody) |
| 1397 | } |
| 1398 | contentType := "application/json" |
| 1399 | if c := fBody.Tag.Get("contentType"); c != "" { |
| 1400 | contentType = c |
| 1401 | } |
| 1402 | if op.RequestBody.Content[contentType] == nil { |
| 1403 | op.RequestBody.Content[contentType] = &MediaType{} |
| 1404 | } |
| 1405 | if op.RequestBody.Content[contentType].Schema == nil { |
| 1406 | hint := getHint(inputType, fBody.Name, op.OperationID+"Request") |
| 1407 | if nameHint := fBody.Tag.Get("nameHint"); nameHint != "" { |
| 1408 | hint = nameHint |
| 1409 | } |
| 1410 | s := SchemaFromField(registry, fBody, hint) |
| 1411 | op.RequestBody.Content[contentType].Schema = s |
| 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | type rawBodyType int |
| 1416 |
no test coverage detected
searching dependent graphs…