git.iko.soy/typeable/openapi3
on master help sign in
add Json-instances for TimeOfDay
commitfeaeb64e299d38aba5b8f8b1f9a9e2cb2e2c63ae authoranneloreegger <annelore.e@hotmail.com> dateSun 16 Jun 2019, 13:59 (7 years ago) parentd75076f
2 files changed+7
src/Data/Swagger/Internal/ParamSchema.hs+3 src/Data/Swagger/Internal/Schema.hs+4
src/Data/Swagger/Internal/ParamSchema.hs+3
@@ -193,6 +193,9 @@ timeParamSchema fmt = mempty
193193instance ToParamSchema Day where
194194 toParamSchema _ = timeParamSchema "date"
195195
196+instance ToParamSchema TimeOfDay where
197+ toParamSchema _ = timeParamSchema "hh:MM:ss"
198+
196199-- |
197200-- >>> toParamSchema (Proxy :: Proxy LocalTime) ^. format
198201-- Just "yyyy-mm-ddThh:MM:ss"
src/Data/Swagger/Internal/Schema.hs+4
@@ -147,6 +147,10 @@ class ToSchema a where
147147 Proxy a -> Declare (Definitions Schema) NamedSchema
148148 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
149149
150+instance ToSchema TimeOfDay where
151+ declareNamedSchema _ = pure $ named "TimeOfDay" $ timeSchema "hh:MM:ss"
152+ & example ?~ toJSON (TimeOfDay 12 33 15)
153+
150154-- | Convert a type into a schema and declare all used schema definitions.
151155declareSchema :: ToSchema a => Proxy a -> Declare (Definitions Schema) Schema
152156declareSchema = fmap _namedSchemaSchema . declareNamedSchema