You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this should be reopened. Go json marshalling and unmarshalling automatically encodes and decodes a field of type []byte as Base64 string.
See https://golang.org/pkg/encoding/json/#Marshal:
Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON value.
I think Swaggo should by default use string as a type for these fields.
Reacted by Alexandros Dorodoulis, Jake-Convictional, Matt Hook, Pasquale Convertini and Bryan Gillespie
@tomquist agreed. Swag labelling []byte type as an integer array is actually a bug. []byte is always marshalled to JSON as a base64 encoded string type.
Activity
easonlin404 commentedon Apr 22, 2019
what's your expected output for base64 encoded? would you provide expected swagger json output ?
prometherion commentedon May 24, 2019
@easonlin404 sorry for the long wait, lots to do :)
Anyway, I'd like to get something like this:
Just to adhere to Swagger standards regarding string formats
ubogdan commentedon Jul 8, 2019
Swagger allready do this. Have you tried ?
prometherion commentedon Jul 16, 2019
I'm not complaining about Swagger but regarding the inability of
swaggoto generate it the right way.ubogdan commentedon Jul 16, 2019
@prometherion as your definition is []byte , why do you expect to be type="string"
ubogdan commentedon Jul 16, 2019
Closed it by mistake.
prometherion commentedon Jul 16, 2019
because I'd like to make requests directly from UI
ubogdan commentedon Jul 17, 2019
I'm going to ask you one more time.
Definition of the struct:
Why are u declaring slice of byte when you expect string in documentation ?
I guess you know the difference between []byte and string .
prometherion commentedon Jul 17, 2019
@ubogdan my bad in the first comment opening the issue :(
I'd like to get the binding
[]byteexpecting the formabase64in the Swagger definition.ubogdan commentedon Aug 19, 2019
@prometherion There is a way to do this
And will produce
tomquist commentedon May 7, 2020
I think this should be reopened. Go json marshalling and unmarshalling automatically encodes and decodes a field of type
[]byteas Base64 string.See https://golang.org/pkg/encoding/json/#Marshal:
I think Swaggo should by default use string as a type for these fields.
Jake-Convictional commentedon Jul 20, 2022
@tomquist agreed. Swag labelling
[]bytetype as an integer array is actually a bug.[]byteis always marshalled to JSON as a base64 encodedstringtype.ubogdan commentedon Jul 21, 2022
This is an open source project, anyone is wellcome to improve it.
pasquale95 commentedon Feb 16, 2024
Have you find a solution for this issue?