git.iko.soy/typeable/openapi3
on master help sign in
add Json-instances for TimeOfDay
feaeb64anneloreegger
src/Data/Swagger/Internal/ParamSchema.hs+3
@@ -193,6 +193,9 @@ timeParamSchema fmt = mempty
193instance ToParamSchema Day where
193instance ToParamSchema Day where
194 toParamSchema _ = timeParamSchema "date"
194 toParamSchema _ = timeParamSchema "date"
195
195
196+instance ToParamSchema TimeOfDay where
197+ toParamSchema _ = timeParamSchema "hh:MM:ss"
198+
196-- |
199-- |
197-- >>> toParamSchema (Proxy :: Proxy LocalTime) ^. format
200-- >>> toParamSchema (Proxy :: Proxy LocalTime) ^. format
198-- Just "yyyy-mm-ddThh:MM:ss"
201-- Just "yyyy-mm-ddThh:MM:ss"
src/Data/Swagger/Internal/Schema.hs+4
@@ -147,6 +147,10 @@ class ToSchema a where
147 Proxy a -> Declare (Definitions Schema) NamedSchema
147 Proxy a -> Declare (Definitions Schema) NamedSchema
148 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
148 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
149
149
150+instance ToSchema TimeOfDay where
151+ declareNamedSchema _ = pure $ named "TimeOfDay" $ timeSchema "hh:MM:ss"
152+ & example ?~ toJSON (TimeOfDay 12 33 15)
153+
150-- | Convert a type into a schema and declare all used schema definitions.
154-- | Convert a type into a schema and declare all used schema definitions.
151declareSchema :: ToSchema a => Proxy a -> Declare (Definitions Schema) Schema
155declareSchema :: ToSchema a => Proxy a -> Declare (Definitions Schema) Schema
152declareSchema = fmap _namedSchemaSchema . declareNamedSchema
156declareSchema = fmap _namedSchemaSchema . declareNamedSchema