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
Form data is halfway between ParamSchema and Schema with an extra property that it can handle SwaggerFile. I think it makes sense to introduce a class ToFormData for that. Instances of this class can be derived generically for records where each field has a ParamSchema instance.
The correspondence of type-level and value-level classes is this:
ToParamSchema — ToHttpApiData;
ToFormData — ToFormUrlEncoded;
ToSchema — ToJSON.
Having ToFormData class with Generic-based deriving should reduce a significant amount of boilerplate.
The problem I currently have with ToFormData class is that swagger2 model does not allow for this class to be pretty:
Basically, FormDataParam should be just Param with the restriction that ParamLocation is ParamFormData. But we cannot specify that constraint in current model.
Actually I don't know if we can specify it at all (without resorting to existentials like SomeParam).
For now we can define a data type for form data parameters together with conversion function:
Form data is halfway between
ParamSchema
andSchema
with an extra property that it can handleSwaggerFile
. I think it makes sense to introduce a classToFormData
for that. Instances of this class can be derived generically for records where each field has aParamSchema
instance.The correspondence of type-level and value-level classes is this:
ToParamSchema
—ToHttpApiData
;ToFormData
—ToFormUrlEncoded
;ToSchema
—ToJSON
.Having
ToFormData
class withGeneric
-based deriving should reduce a significant amount of boilerplate.The problem I currently have with
ToFormData
class is thatswagger2
model does not allow for this class to be pretty:Basically,
FormDataParam
should be justParam
with the restriction thatParamLocation
isParamFormData
. But we cannot specify that constraint in current model.Actually I don't know if we can specify it at all (without resorting to existentials like
SomeParam
).For now we can define a data type for form data parameters together with conversion function:
@dmjio what do you think about this hacky solution?
The text was updated successfully, but these errors were encountered: