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