danielgtaylor / danielgtaylor/huma

Is there a simpler solution to add an example to the requestBody?

Open
#991 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.4k
Forks
285
Avg merge
40m
Merged PRs (30d)
1

Description

My current solution is as follows:

```golang
var (
createTaskExample = utils.MustUnmarshalJSON[map[string]any](`
{
"payload": {

},
"priority": 0
}
`)
)

huma.Operation{
Tags: []string{enums.OpenAPITagManagement.String()},
OperationID: "createTask",
Method: http.MethodPost,
Path: "/tasks/create",
Summary: "create task",
RequestBody: &huma.RequestBody{
Content: map[string]*huma.MediaType{
"application/json": {
Example: createTaskExample,
},
},
},
}
```

Is there a simpler solution to add an example to the requestBody?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.