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
Right now, using the default parameter in openAPI specs does functionally nothing in the generator.
We could improve the strict generator by setting the query parameters to the default values set, and not have a pointer to them in the code, marking them as optional.
The text was updated successfully, but these errors were encountered:
An up vote for addtional support for default values from me. I came across this when I had a query param that had a default value of false, found myself having check if it was nil and assuming a default which introduces a disconnect between the OAPI spec and the code:
varfieldboolifparams.Field!=nil&¶ms.Field {
field=params.Field
}
// do something with `field`
I think the auto-generated client code requires no changes since a pointer value (!= nil) is used to differentate between a user provided value and no value.
So as you suggest, if the schema has a default value then having that set automatically if the request does not give a value would be a start. Dropping the pointer for a more user-friendly experience would be the next step. In my example I could then just use params.Field directly.
Right now, using the
default
parameter in openAPI specs does functionally nothing in the generator.We could improve the strict generator by setting the query parameters to the default values set, and not have a pointer to them in the code, marking them as optional.
The text was updated successfully, but these errors were encountered: