git.iko.soy/typeable/openapi3
on 67f8475 help sign in
typeable/openapi3/src/Data/Swagger/SchemaOptions.hs
37 lines 1.4 kB history raw
1module Data.Swagger.SchemaOptions where
3-- | Options that specify how to encode your type to Swagger schema.
4data SchemaOptions = SchemaOptions
5 { -- | Function applied to field labels. Handy for removing common record prefixes for example.
6 fieldLabelModifier :: String -> String
7 -- | Function applied to constructor tags which could be handy for lower-casing them for example.
8 , constructorTagModifier :: String -> String
9 -- | Function applied to datatype name.
10 , datatypeNameModifier :: String -> String
11 -- | If @'True'@ the constructors of a datatype, with all nullary constructors,
12 -- will be encoded to a string enumeration schema with the constructor tags as possible values.
13 , allNullaryToStringTag :: Bool
14 -- | Hide the field name when a record constructor has only one field, like a newtype.
15 , unwrapUnaryRecords :: Bool
16 }
18-- | Default encoding @'SchemaOptions'@.
19--
20-- @
21-- 'SchemaOptions'
22-- { 'fieldLabelModifier' = id
23-- , 'constructorTagModifier' = id
24-- , 'datatypeNameModifier' = id
25-- , 'allNullaryToStringTag' = True
26-- , 'unwrapUnaryRecords' = False
27-- }
28-- @
29defaultSchemaOptions :: SchemaOptions
30defaultSchemaOptions = SchemaOptions
31 { fieldLabelModifier = id
32 , constructorTagModifier = id
33 , datatypeNameModifier = id
34 , allNullaryToStringTag = True
35 , unwrapUnaryRecords = False
36 }