MCPcopy
hub / github.com/danielgtaylor/huma / setRequestBodyFromBody

Function setRequestBodyFromBody

huma.go:1394–1413  ·  view source on GitHub ↗

setRequestBodyFromBody configures op.RequestBody from the Body field.

(op *Operation, registry Registry, fBody reflect.StructField, inputType reflect.Type)

Source from the content-addressed store, hash-verified

1392
1393// setRequestBodyFromBody configures op.RequestBody from the Body field.
1394func 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
1415type rawBodyType int
1416

Callers 1

processInputTypeFunction · 0.85

Calls 4

setRequestBodyRequiredFunction · 0.85
getHintFunction · 0.85
SchemaFromFieldFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…