git.iko.soy/typeable/openapi3
on master help sign in
Fix doctests
5008f9dNickolay Kudasov
src/Data/Swagger/Internal/Schema.hs+2−2
@@ -145,7 +145,7 @@ declareSchema = fmap _namedSchemaSchema . declareNamedSchema
145-- >>> toNamedSchema (Proxy :: Proxy Day) ^. name
145-- >>> toNamedSchema (Proxy :: Proxy Day) ^. name
146-- Just "Day"
146-- Just "Day"
147-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. schema)
147-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. schema)
148−-- "{\"format\":\"date\",\"type\":\"string\"}"
148+-- "{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}"
149toNamedSchema :: ToSchema a => proxy a -> NamedSchema
149toNamedSchema :: ToSchema a => proxy a -> NamedSchema
150toNamedSchema = undeclare . declareNamedSchema
150toNamedSchema = undeclare . declareNamedSchema
151
151
@@ -245,7 +245,7 @@ inlineAllSchemas = inlineSchemasWhen (const True)
245-- | Convert a type into a schema without references.
245-- | Convert a type into a schema without references.
246--
246--
247-- >>> encode $ toInlinedSchema (Proxy :: Proxy [Day])
247-- >>> encode $ toInlinedSchema (Proxy :: Proxy [Day])
248−-- "{\"items\":{\"format\":\"date\",\"type\":\"string\"},\"type\":\"array\"}"
248+-- "{\"items\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"},\"type\":\"array\"}"
249--
249--
250-- __WARNING:__ @'toInlinedSchema'@ will produce infinite schema
250-- __WARNING:__ @'toInlinedSchema'@ will produce infinite schema
251-- when inlining recursive schemas.
251-- when inlining recursive schemas.
src/Data/Swagger/Operation.hs+2−2
@@ -120,7 +120,7 @@ applyTagsFor ops ts swag = swag
120-- necessary schema definitions.
120-- necessary schema definitions.
121--
121--
122-- >>> encode $ runDeclare (declareResponse (Proxy :: Proxy Day)) mempty
122-- >>> encode $ runDeclare (declareResponse (Proxy :: Proxy Day)) mempty
123−-- "[{\"Day\":{\"format\":\"date\",\"type\":\"string\"}},{\"description\":\"\",\"schema\":{\"$ref\":\"#/definitions/Day\"}}]"
123+-- "[{\"Day\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}},{\"description\":\"\",\"schema\":{\"$ref\":\"#/definitions/Day\"}}]"
124declareResponse :: ToSchema a => proxy a -> Declare (Definitions Schema) Response
124declareResponse :: ToSchema a => proxy a -> Declare (Definitions Schema) Response
125declareResponse proxy = do
125declareResponse proxy = do
126 s <- declareSchemaRef proxy
126 s <- declareSchemaRef proxy
@@ -140,7 +140,7 @@ declareResponse proxy = do
140-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
140-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
141-- >>> let res = declareResponse (Proxy :: Proxy Day)
141-- >>> let res = declareResponse (Proxy :: Proxy Day)
142-- >>> encode $ api & setResponse 200 res
142-- >>> encode $ api & setResponse 200 res
143−-- "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/Day\"},\"description\":\"\"}}}}},\"definitions\":{\"Day\":{\"format\":\"date\",\"type\":\"string\"}}}"
143+-- "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/Day\"},\"description\":\"\"}}}}},\"definitions\":{\"Day\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}}}"
144--
144--
145-- See also @'setResponseWith'@.
145-- See also @'setResponseWith'@.
146setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
146setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger