git.iko.soy/typeable/swagger2
on master help sign in
Fix doctests
commit5008f9d4f1442e9878eb5d878eec31ca2d2f789c authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateFri 22 Jul 2016, 02:08 (10 years ago) parent0f43d15
2 files changed+4−4
src/Data/Swagger/Internal/Schema.hs+2−2 src/Data/Swagger/Operation.hs+2−2
src/Data/Swagger/Internal/Schema.hs+2−2
@@ -145,7 +145,7 @@ declareSchema = fmap _namedSchemaSchema . declareNamedSchema
145145-- >>> toNamedSchema (Proxy :: Proxy Day) ^. name
146146-- Just "Day"
147147-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. schema)
148−-- "{\"format\":\"date\",\"type\":\"string\"}"
148+-- "{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}"
149149toNamedSchema :: ToSchema a => proxy a -> NamedSchema
150150toNamedSchema = undeclare . declareNamedSchema
151151
@@ -245,7 +245,7 @@ inlineAllSchemas = inlineSchemasWhen (const True)
245245-- | Convert a type into a schema without references.
246246--
247247-- >>> 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\"}"
249249--
250250-- __WARNING:__ @'toInlinedSchema'@ will produce infinite schema
251251-- when inlining recursive schemas.
src/Data/Swagger/Operation.hs+2−2
@@ -120,7 +120,7 @@ applyTagsFor ops ts swag = swag
120120-- necessary schema definitions.
121121--
122122-- >>> 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\"}}]"
124124declareResponse :: ToSchema a => proxy a -> Declare (Definitions Schema) Response
125125declareResponse proxy = do
126126 s <- declareSchemaRef proxy
@@ -140,7 +140,7 @@ declareResponse proxy = do
140140-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
141141-- >>> let res = declareResponse (Proxy :: Proxy Day)
142142-- >>> 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\"}}}"
144144--
145145-- See also @'setResponseWith'@.
146146setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger