git.iko.soy/typeable/openapi3
on master help sign in
Add example to cabal and update it
commit867ff824179ac9b43145a36a17b70cc66322177a authorMaxim Koltsov <kolmax94@gmail.com> dateMon 3 Aug 2020, 17:54 (6 years ago) parent7f9addf
2 files changed+12−10
examples/hackage.hs+6−10 openapi3.cabal+6
examples/hackage.hs+6−10
@@ -48,7 +48,7 @@ newtype Package = Package { packageName :: Text }
4848 deriving (Generic, ToSchema)
4949
5050hackageSwagger :: Swagger
51−hackageSwagger = spec & definitions .~ defs
51+hackageSwagger = spec & components.schemas .~ defs
5252 where
5353 (defs, spec) = runDeclare declareHackageSwagger mempty
5454
@@ -58,26 +58,22 @@ declareHackageSwagger = do
5858 let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)
5959
6060 -- responses
61− userSummaryResponse <- declareResponse (Proxy :: Proxy UserSummary)
62− userDetailedResponse <- declareResponse (Proxy :: Proxy UserDetailed)
63− packagesResponse <- declareResponse (Proxy :: Proxy [Package])
61+ userSummaryResponse <- declareResponse "application/json" (Proxy :: Proxy UserSummary)
62+ userDetailedResponse <- declareResponse "application/json" (Proxy :: Proxy UserDetailed)
63+ packagesResponse <- declareResponse "application/json" (Proxy :: Proxy [Package])
6464
6565 return $ mempty
6666 & paths .~
6767 [ ("/users", mempty & get ?~ (mempty
68− & produces ?~ MimeList ["application/json"]
6968 & at 200 ?~ Inline userSummaryResponse))
7069 , ("/user/{username}", mempty & get ?~ (mempty
71− & produces ?~ MimeList ["application/json"]
7270 & parameters .~ [ Inline $ mempty
7371 & name .~ "username"
7472 & required ?~ True
75− & schema .~ ParamOther (mempty
76− & in_ .~ ParamPath
77− & paramSchema .~ usernameParamSchema) ]
73+ & in_ .~ ParamPath
74+ & schema ?~ Inline usernameParamSchema ]
7875 & at 200 ?~ Inline userDetailedResponse))
7976 , ("/packages", mempty & get ?~ (mempty
80− & produces ?~ MimeList ["application/json"]
8177 & at 200 ?~ Inline packagesResponse))
8278 ]
8379
openapi3.cabal+6
@@ -145,6 +145,12 @@ test-suite doctests
145145 main-is: doctests.hs
146146 type: exitcode-stdio-1.0
147147
148+executable example
149+ hs-source-dirs: examples
150+ main-is: hackage.hs
151+ default-language: Haskell2010
152+ build-depends: base, aeson, lens, openapi3, text
153+
148154source-repository head
149155 type: git
150156 location: https://github.com/biocad/openapi3.git