git.iko.soy/typeable/swagger2
on master help sign in
Fix tests and examples for NamedSchema
commiteb46ba7bab55fca8f6f5d7282639c9f0e2546bd1 authorCatherine Galkina <catherine@getshoptv.com> dateThu 21 Jan 2016, 14:48 (11 years ago) parent5beb804
2 files changed+9−5
src/Data/Swagger/Internal/Schema.hs+8−4 test/Data/Swagger/SchemaSpec.hs+1−1
src/Data/Swagger/Internal/Schema.hs+8−4
@@ -120,11 +120,15 @@ declareSchema = fmap _namedSchemaSchema . declareNamedSchema
120120
121121-- | Convert a type into an optionally named schema.
122122--
123−-- >>> encode <$> toNamedSchema (Proxy :: Proxy String)
124−-- (Nothing,"{\"type\":\"string\"}")
123+-- >>> toNamedSchema (Proxy :: Proxy String) ^. namedSchemaName
124+-- Nothing
125+-- >>> encode (toNamedSchema (Proxy :: Proxy String) ^. namedSchemaSchema)
126+-- "{\"type\":\"string\"}"
125127--
126−-- >>> encode <$> toNamedSchema (Proxy :: Proxy Day)
127−-- (Just "Day","{\"format\":\"date\",\"type\":\"string\"}")
128+-- >>> toNamedSchema (Proxy :: Proxy Day) ^. namedSchemaName
129+-- Just "Day"
130+-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. namedSchemaSchema)
131+-- "{\"format\":\"date\",\"type\":\"string\"}"
128132toNamedSchema :: ToSchema a => proxy a -> NamedSchema
129133toNamedSchema = undeclare . declareNamedSchema
130134
test/Data/Swagger/SchemaSpec.hs+1−1
@@ -345,7 +345,7 @@ newtype Inlined a = Inlined { getInlined :: a }
345345instance ToSchema a => ToSchema (Inlined a) where
346346 declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
347347 where
348− unname (_, schema) = (Nothing, schema)
348+ unname (NamedSchema _ schema) = NamedSchema Nothing schema
349349
350350newtype Players = Players [Inlined Player]
351351 deriving (Generic, ToSchema)