git.iko.soy/typeable/openapi3
on master help sign in
Add example to cabal and update it
867ff82Maxim Koltsov
examples/hackage.hs+6−10
@@ -48,7 +48,7 @@ newtype Package = Package { packageName :: Text }
48 deriving (Generic, ToSchema)
48 deriving (Generic, ToSchema)
49
49
50hackageSwagger :: Swagger
50hackageSwagger :: Swagger
51−hackageSwagger = spec & definitions .~ defs
51+hackageSwagger = spec & components.schemas .~ defs
52 where
52 where
53 (defs, spec) = runDeclare declareHackageSwagger mempty
53 (defs, spec) = runDeclare declareHackageSwagger mempty
54
54
@@ -58,26 +58,22 @@ declareHackageSwagger = do
58 let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)
58 let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)
59
59
60 -- responses
60 -- responses
61− userSummaryResponse <- declareResponse (Proxy :: Proxy UserSummary)
61+ userSummaryResponse <- declareResponse "application/json" (Proxy :: Proxy UserSummary)
62− userDetailedResponse <- declareResponse (Proxy :: Proxy UserDetailed)
62+ userDetailedResponse <- declareResponse "application/json" (Proxy :: Proxy UserDetailed)
63− packagesResponse <- declareResponse (Proxy :: Proxy [Package])
63+ packagesResponse <- declareResponse "application/json" (Proxy :: Proxy [Package])
64
64
65 return $ mempty
65 return $ mempty
66 & paths .~
66 & paths .~
67 [ ("/users", mempty & get ?~ (mempty
67 [ ("/users", mempty & get ?~ (mempty
68− & produces ?~ MimeList ["application/json"]
69 & at 200 ?~ Inline userSummaryResponse))
68 & at 200 ?~ Inline userSummaryResponse))
70 , ("/user/{username}", mempty & get ?~ (mempty
69 , ("/user/{username}", mempty & get ?~ (mempty
71− & produces ?~ MimeList ["application/json"]
72 & parameters .~ [ Inline $ mempty
70 & parameters .~ [ Inline $ mempty
73 & name .~ "username"
71 & name .~ "username"
74 & required ?~ True
72 & required ?~ True
75− & schema .~ ParamOther (mempty
76− & in_ .~ ParamPath
73+ & in_ .~ ParamPath
77− & paramSchema .~ usernameParamSchema) ]
74+ & schema ?~ Inline usernameParamSchema ]
78 & at 200 ?~ Inline userDetailedResponse))
75 & at 200 ?~ Inline userDetailedResponse))
79 , ("/packages", mempty & get ?~ (mempty
76 , ("/packages", mempty & get ?~ (mempty
80− & produces ?~ MimeList ["application/json"]
81 & at 200 ?~ Inline packagesResponse))
77 & at 200 ?~ Inline packagesResponse))
82 ]
78 ]
83
79
openapi3.cabal+6
@@ -145,6 +145,12 @@ test-suite doctests
145 main-is: doctests.hs
145 main-is: doctests.hs
146 type: exitcode-stdio-1.0
146 type: exitcode-stdio-1.0
147
147
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+
148source-repository head
154source-repository head
149 type: git
155 type: git
150 location: https://github.com/biocad/openapi3.git
156 location: https://github.com/biocad/openapi3.git