git.iko.soy/typeable/swagger2
on master help sign in
Fix tests and examples for NamedSchema
eb46ba7Catherine Galkina
src/Data/Swagger/Internal/Schema.hs+8−4
@@ -120,11 +120,15 @@ declareSchema = fmap _namedSchemaSchema . declareNamedSchema
120
120
121-- | Convert a type into an optionally named schema.
121-- | Convert a type into an optionally named schema.
122--
122--
123−-- >>> encode <$> toNamedSchema (Proxy :: Proxy String)
123+-- >>> toNamedSchema (Proxy :: Proxy String) ^. namedSchemaName
124+-- Nothing
125+-- >>> encode (toNamedSchema (Proxy :: Proxy String) ^. namedSchemaSchema)
124−-- (Nothing,"{\"type\":\"string\"}")
126+-- "{\"type\":\"string\"}"
125--
127--
128+-- >>> toNamedSchema (Proxy :: Proxy Day) ^. namedSchemaName
129+-- Just "Day"
126−-- >>> encode <$> toNamedSchema (Proxy :: Proxy Day)
130+-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. namedSchemaSchema)
127−-- (Just "Day","{\"format\":\"date\",\"type\":\"string\"}")
131+-- "{\"format\":\"date\",\"type\":\"string\"}"
128toNamedSchema :: ToSchema a => proxy a -> NamedSchema
132toNamedSchema :: ToSchema a => proxy a -> NamedSchema
129toNamedSchema = undeclare . declareNamedSchema
133toNamedSchema = undeclare . declareNamedSchema
130
134
test/Data/Swagger/SchemaSpec.hs+1−1
@@ -345,7 +345,7 @@ newtype Inlined a = Inlined { getInlined :: a }
345instance ToSchema a => ToSchema (Inlined a) where
345instance ToSchema a => ToSchema (Inlined a) where
346 declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
346 declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
347 where
347 where
348− unname (_, schema) = (Nothing, schema)
348+ unname (NamedSchema _ schema) = NamedSchema Nothing schema
349
349
350newtype Players = Players [Inlined Player]
350newtype Players = Players [Inlined Player]
351 deriving (Generic, ToSchema)
351 deriving (Generic, ToSchema)