@@ -59,10 +59,10 @@ import qualified Data.HashSet.InsOrd as InsOrdHS
5959-- | Prepend path piece to all operations of the spec.
6060-- Leading and trailing slashes are trimmed/added automatically.
6161--
62−-- >>> let api = (mempty :: Swagger) & paths .~ [("/info", mempty)]
62+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/info", mempty)]
6363-- >>> BSL.putStrLn $ encode $ prependPath "user/{user_id}" api ^. paths
6464-- {"/user/{user_id}/info":{}}
65−prependPath :: FilePath -> Swagger -> Swagger
65+prependPath :: FilePath -> OpenApi -> OpenApi
6666prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
6767 where
6868 x </> y = case trim y of
@@ -72,7 +72,7 @@ prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
7272 trim = dropWhile (== '/') . dropWhileEnd (== '/')
7373
7474-- | All operations of a Swagger spec.
75−allOperations :: Traversal' Swagger Operation
75+allOperations :: Traversal' OpenApi Operation
7676allOperations = paths.traverse.template
7777
7878-- | @'operationsOf' sub@ will traverse only those operations
@@ -80,13 +80,13 @@ allOperations = paths.traverse.template
8080-- by both path and method.
8181--
8282-- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK"
83−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
84−-- >>> let sub = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
83+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
84+-- >>> let sub = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
8585-- >>> BSL.putStrLn $ encode api
8686-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
8787-- >>> BSL.putStrLn $ encode $ api & operationsOf sub . at 404 ?~ "Not found"
8888-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"404":{"description":"Not found"},"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
89−operationsOf :: Swagger -> Traversal' Swagger Operation
89+operationsOf :: OpenApi -> Traversal' OpenApi Operation
9090operationsOf sub = paths.itraversed.withIndex.subops
9191 where
9292 -- | Traverse operations that correspond to paths and methods of the sub API.
@@ -108,12 +108,12 @@ operationsOf sub = paths.itraversed.withIndex.subops
108108-- @
109109-- 'applyTags' = 'applyTagsFor' 'allOperations'
110110-- @
111−applyTags :: [Tag] -> Swagger -> Swagger
111+applyTags :: [Tag] -> OpenApi -> OpenApi
112112applyTags = applyTagsFor allOperations
113113
114114-- | Apply tags to a part of Swagger spec and update the global
115115-- list of tags.
116−applyTagsFor :: Traversal' Swagger Operation -> [Tag] -> Swagger -> Swagger
116+applyTagsFor :: Traversal' OpenApi Operation -> [Tag] -> OpenApi -> OpenApi
117117applyTagsFor ops ts swag = swag
118118 & ops . tags %~ (<> InsOrdHS.fromList (map _tagName ts))
119119 & tags %~ (<> InsOrdHS.fromList ts)
@@ -141,13 +141,13 @@ declareResponse cType proxy = do
141141--
142142-- Example:
143143--
144−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
144+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
145145-- >>> let res = declareResponse "application/json" (Proxy :: Proxy Day)
146146-- >>> BSL.putStrLn $ encode $ api & setResponse 200 res
147147-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Day"}}},"description":""}}}}},"components":{"schemas":{"Day":{"example":"2016-07-22","format":"date","type":"string"}}}}
148148--
149149-- See also @'setResponseWith'@.
150−setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
150+setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
151151setResponse = setResponseFor allOperations
152152
153153-- | Set or update response for all operations.
@@ -161,7 +161,7 @@ setResponse = setResponseFor allOperations
161161-- @
162162--
163163-- See also @'setResponse'@.
164−setResponseWith :: (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
164+setResponseWith :: (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
165165setResponseWith = setResponseForWith allOperations
166166
167167-- | Set response for specified operations.
@@ -170,7 +170,7 @@ setResponseWith = setResponseForWith allOperations
170170-- If the response already exists it will be overwritten.
171171--
172172-- See also @'setResponseForWith'@.
173−setResponseFor :: Traversal' Swagger Operation -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
173+setResponseFor :: Traversal' OpenApi Operation -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
174174setResponseFor ops code dres swag = swag
175175 & components.schemas %~ (<> defs)
176176 & ops . at code ?~ Inline res
@@ -184,7 +184,7 @@ setResponseFor ops code dres swag = swag
184184-- then just the new response is used.
185185--
186186-- See also @'setResponseFor'@.
187−setResponseForWith :: Traversal' Swagger Operation -> (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
187+setResponseForWith :: Traversal' OpenApi Operation -> (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
188188setResponseForWith ops f code dres swag = swag
189189 & components.schemas %~ (<> defs)
190190 & ops . at code %~ Just . Inline . combine