-
Notifications
You must be signed in to change notification settings - Fork 59
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
ToSchema class with Generic deriving and other helpers #10
Conversation
@fizruk, fantastic work, this is definitely useful for I think putting the generics based derivations in Still wondering if Overall, great work 👍 |
26154ea
to
474cbda
Compare
In case of unary non-record alternative we retain field's name in case we need to $ref it when constructing schema for sum type. Note that this only affects sum types, e.g. -- some type with named schema to $ref data A = ... -- schema for B will reuse schema for A, not $ref to it data B = B A deriving (Generic, ToSchema) -- schema for C will $ref A for C1 constructor data C = C1 A | ... deriving (Generic, ToSchema)
Just to keep you in loop, in recent commits I have
|
e39ef1f
to
e35f806
Compare
919b607
to
ae89d5f
Compare
This PR has grown big and before I start to change things even further I think it is time to merge and release. I still am a bit uncomfortable with data Color = White | Black deriving (Generic, ToSchema)
data Dog = Dog { nick :: String, color :: Color } deriving (Generic, ToSchema)
data Person = Person { name :: String, dog :: Dog } deriving (Generic, ToSchema)
type PersonAPI
= "person" :> ReqBody Person :> Post () How would you know to add The solution I think should be for @dmjio what do you think? |
ToSchema class with Generic deriving and other helpers
👍 |
* Include the scheme when using http security * Add HttpSchemeCustom and optional bearerFormat
What's in:
ToSchema
class with defaultGeneric
-based implementation;genericToSchema
working for some base types and record data types;toSchemaBoundedIntegral
andtoSchemaBoundedEnum
helpers;Options
similar toData.Aeson.Options
(I have addedfieldLabelModifier
, what else do we need?);ToSchema
instances for common types;ToSchema
instances fortime
types;ToParam
/ToHeader
classes (see ToParamSchema class #17);@dmjio would this be useful for
servant-swagger
?