Replace custom struct for another basic type #55
Unanswered
SionParera
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
We are currently migrating from https://github.com/swaggo/swag, and we have found a small issue with our current code. We have some custom types that are meant for database interaction, this types are structs that have a boolean field that means if the value is null (as retreived from the ddbb) and the actual value field.
As in golang integer fields can't be null we need this workaround for them to distinguish when we retrieve a null or a 0 from the ddbb.
From the API standpoint, these are normal integer fields, so we need a way to tell the parser that treat these types as normal integers.
For example we currently have this struct:
type SampleStruct struct {
Id NullInt64
json:"id" example:"1" extensions:"x-order=1"
}
type NullInt64 struct {
Int64 int64
Valid bool // Valid is true if Int64 is not NULL
}
In the library we used before (https://github.com/swaggo/swag) we could create an additional file named ".swaggo" with this command:
replace NullInt64 integer
That told the parser to treat all NullInt64 as they were integers. Is there a way to accomplish this behaviour with go-swagger3?? I have searched inside the documentation but found nothing.
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions