servant-swagger 0.1.1 → 0.1.2
raw patch · 4 files changed
+18/−11 lines, 4 filesdep ~swagger2
Dependency ranges changed: swagger2
Files
- README.md +2/−2
- servant-swagger.cabal +3/−3
- src/Servant/Swagger/Internal.hs +11/−4
- test/Servant/SwaggerSpec.hs +2/−2
README.md view
@@ -5,7 +5,7 @@ [](http://stackage.org/lts/package/servant-swagger) [](http://stackage.org/nightly/package/servant-swagger) -This project converts [servant](https://github.com/haskell-servant/servant) APIs into Swagger 2.0 specification.+This project converts [servant](https://github.com/haskell-servant/servant) APIs into Swagger 2.0 conforming json.  @@ -111,7 +111,7 @@ "get":{ "responses":{ "404":{- "description":"id not found"+ "description":"`id` not found" }, "200":{ "schema":{
servant-swagger.cabal view
@@ -1,5 +1,5 @@ name: servant-swagger-version: 0.1.1+version: 0.1.2 synopsis: Generate Swagger specification for your servant API. description: Please see README.md homepage: https://github.com/dmjio/servant-swagger@@ -33,7 +33,7 @@ , http-media , lens , servant- , swagger2+ , swagger2 >= 1 && <2 , text , unordered-containers default-language: Haskell2010@@ -50,7 +50,7 @@ , lens , servant , servant-swagger- , swagger2+ , swagger2 >= 1 && <2 , text , time other-modules:
src/Servant/Swagger/Internal.hs view
@@ -139,16 +139,22 @@ addResponse :: HttpStatusCode -> Response -> Swagger -> Swagger addResponse = addResponseWith (\_old new -> new) +-- | Format given text as inline code in Markdown.+markdownCode :: Text -> Text+markdownCode s = "`" <> s <> "`"+ addDefaultResponse404 :: ParamName -> Swagger -> Swagger-addDefaultResponse404 name = addResponseWith (\old _new -> alter404 old) 404 response404+addDefaultResponse404 pname = addResponseWith (\old _new -> alter404 old) 404 response404 where+ name = markdownCode pname description404 = name <> " not found" alter404 = description %~ ((name <> " or ") <>) response404 = mempty & description .~ description404 addDefaultResponse400 :: ParamName -> Swagger -> Swagger-addDefaultResponse400 name = addResponseWith (\old _new -> alter400 old) 400 response400+addDefaultResponse400 pname = addResponseWith (\old _new -> alter400 old) 400 response400 where+ name = markdownCode pname description400 = "Invalid " <> name alter400 = description %~ (<> (" or " <> name)) response400 = mempty & description .~ description400@@ -304,8 +310,9 @@ name = "body" (defs, ref) = runDeclare (declareSchemaRef (Proxy :: Proxy a)) mempty param = mempty- & paramName .~ "body"- & paramSchema .~ ParamBody ref+ & paramName .~ "body"+ & paramRequired ?~ True+ & paramSchema .~ ParamBody ref -- ======================================================================= -- Below are the definitions that should be in Servant.API.ContentTypes
test/Servant/SwaggerSpec.hs view
@@ -91,7 +91,7 @@ "schema": { "$ref":"#/definitions/Todo" }, "description": "" },- "404": { "description": "id not found" }+ "404": { "description": "`id` not found" } }, "produces": [ "application/json" ], "parameters":@@ -283,7 +283,7 @@ "get":{ "responses":{ "404":{- "description":"username not found"+ "description":"`username` not found" }, "200":{ "schema":{