-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalise over the Swagger datatype. #89
base: master
Are you sure you want to change the base?
Conversation
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value. By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value. With this patch, we do not perform any aeson-related translation in the servant-swagger-ui code, and simply use the original datatype. It is servant's own responsibility to handle the actual conversion of the datatype to JSON.
Thanks! This was my original intention, but I did not want to introduce a type parameter and thus break the package API. BTW, why is field order important for your use case? |
Thanks for the quick reply! Regarding your question, I think it's very strange if you have some JSON object with schema
and it ends up being displayed as:
instead. And that's still a relatively modest example with only seven fields. Documentation is intended for a human reader, so order carries logical content. If breaking the API really is a concern (I think it's a modest change, with an easy migration path), then another option would be to introduce something like
and use that instead of |
Aha, I see your point now, thanks. But does using Re breaking change: I propose to mark current |
I don't think it's part of the actual specification or documentation of |
@maksbotan As to migration path, I think my personal opinion would be that it's not worth it (people who don't want the change right now would not be forced to upgrade immediately). But if you want to preserve the old API, temporarily or not, then I'd probably still use the wrapped |
FWIW, my migration patch to the version in this patch was just adding - :<|> SwaggerSchemaUI "swagger-ui" "swagger.json"
+ :<|> SwaggerSchemaUI "swagger-ui" "swagger.json" OpenApi |
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value. By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value. With this patch, we do not perform any aeson-related translation in the servant-swagger-ui code, and simply use the original datatype. It is servant's own responsibility to handle the actual conversion of the datatype to JSON. Follow-up to haskell-servant#89. Co-Authored-By: srk <[email protected]>
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value. By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value. With this patch, we do not perform any aeson-related translation in the servant-swagger-ui code, and simply use the original datatype. It is servant's own responsibility to handle the actual conversion of the datatype to JSON. Based on haskell-servant#89
Are there plans to have this, or the rebase in #92 merged, @maksbotan or @phadej? |
Ping. Can this be merged? |
Ping. Can this be merged please? |
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value. By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value. With this patch, we do not perform any aeson-related translation in the servant-swagger-ui code, and simply use the original datatype. It is servant's own responsibility to handle the actual conversion of the datatype to JSON. Follow-up to haskell-servant#89. Co-Authored-By: srk <[email protected]>
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value. By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value. With this patch, we do not perform any aeson-related translation in the servant-swagger-ui code, and simply use the original datatype. It is servant's own responsibility to handle the actual conversion of the datatype to JSON. Follow-up to haskell-servant#89. Co-Authored-By: srk <[email protected]>
This change modifies the previously introduced generalisation of the Haskell datatype that holds the Swagger specification to an aeson Value, see 6576953
By using an aeson Value, all ordering information of object fields is being lost. This information is in principle preserved by aeson, when going via Encoding rather than Value.
This effectively introduces a regression when used with
swagger2
. Foropenapi3
, there's an independent problem that theSchema
type does not have a proper definition oftoEncoding
, soopenapi3
loses ordering information of object fields independently right now.With this patch, we do not perform any
aeson
-related translation in theservant-swagger-ui
code, and simply use the original datatype. It isservant
's own responsibility to handle the actual conversion of the datatype to JSON. This means that all theservant-swagger-ui
packages need neither a dependency on theswagger2
/openapi3
packages, nor onaeson
. The "cost" is an additional type parameter of theSwaggerSchemaUI
type.This is an interface-breaking change.