-
|
I basically want a file upload button as we can do in the swagger ui by doing this @Param image formData file true "Asset file to upload"here is my sample route - type CreateReviewInput struct {
Comment string `db:"comment" json:"comment"`
AttachedFileNames []string `db:"attached_file_names" json:"attached_file_names"`
}
type CreateReviewRequest struct {
UserAgent string `header:"User-Agent"`
Body CreateReviewInput `json:"body"`
RawBody multipart.Form
}
huma.Register(api, huma.Operation{
Path: path,
Method: "POST",
Tags: []string{"Review"},
OperationID: "create-review",
Middlewares: huma.Middlewares{middleware.UserAuthenticationMiddleware(tokenService)},
}, func(ctx context.Context, i *CreateReviewRequest) (*createReviewResponse, error) {}
}I want it to appear like this Apparently this needs to be setup https://docs.stoplight.io/docs/platform/c2f20944173d7-work-with-media-types |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Currently, the UI comes like this - |
Beta Was this translation helpful? Give feedback.
-
|
Hey @danielgtaylor got any idea on this? If this needs some contribution, do tell me. Thanks. |
Beta Was this translation helpful? Give feedback.
-
|
Stoplight wants either #422 aims to fix that by adding On a side note, draft PR #415 is on the way to improve support and documentation for file uploads. |
Beta Was this translation helpful? Give feedback.


Stoplight wants either
contentEncoding: "base64"orcontentMediaType: "application/octet-stream"to identify a field as a file input.#422 aims to fix that by adding
contentMediaType: "application/octet-stream"whenever the format defined is the schema isbinary.Alternatively, you could use base64 (
schema.ContentEncoding = "base64") encoding if that works for you, though that involves encoding/decoding the b64 string both on the client and server sides.On a side note, draft PR #415 is on the way to improve support and documentation for file uploads.