huma icon indicating copy to clipboard operation
huma copied to clipboard

Docs UI doesn't handle multiple cookies properly

Open erikborsos opened this issue 1 year ago • 2 comments

I've noticed an issue (maybe it's a skill issue from my side) with how the docs page displays multiple cookies.

When only a single cookie is set as a result, everything appears fine in the UI. However, when multiple cookies are set, the UI doesn't seem to render it correctly (particularly in nesting).

Set single cookie:

type SingleOutput struct {
	SetCookie *http.Cookie `header:"Set-Cookie"`
}

Result:

image

Set multiple cookies:

type MultipleOutput struct {
	SetCookie []*http.Cookie `header:"Set-Cookie"`
}

Result: image

I can't fold in the Set-Cookie object, which can be a bit confusing if there is more header information set.

erikborsos avatar Apr 22 '24 23:04 erikborsos

Nice find, this is a bug as it should be treated as a string.

danielgtaylor avatar Apr 25 '24 06:04 danielgtaylor

@danielgtaylor It looks like in the case of a slice of []*http.Cookie, it is nesting into the cookie object. So it seems if we can stop nesting if it is a []*http.Cookie type, that should resolve this issue.

I'm not familiar enough with the code that does the reflection to generate the schema in Huma right now since I'm fairly new to the project, so I'm not sure of the "best" way to accomplish this. I'm not sure if the right spot is to throw it into _findInType, or if it belongs in a better spot.

krisatverbidio avatar Jul 05 '24 20:07 krisatverbidio