@@ -59,10 +59,10 @@ import qualified Data.HashSet.InsOrd as InsOrdHS
59-- | Prepend path piece to all operations of the spec.
59-- | Prepend path piece to all operations of the spec.
60-- Leading and trailing slashes are trimmed/added automatically.
60-- Leading and trailing slashes are trimmed/added automatically.
62−-- >>> let api = (mempty :: Swagger) & paths .~ [("/info", mempty)]
62+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/info", mempty)]
63-- >>> BSL.putStrLn $ encode $ prependPath "user/{user_id}" api ^. paths
63-- >>> BSL.putStrLn $ encode $ prependPath "user/{user_id}" api ^. paths
64-- {"/user/{user_id}/info":{}}
64-- {"/user/{user_id}/info":{}}
65−prependPath :: FilePath -> Swagger -> Swagger
65+prependPath :: FilePath -> OpenApi -> OpenApi
66prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
66prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
68 x </> y = case trim y of
68 x </> y = case trim y of
@@ -72,7 +72,7 @@ prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
72 trim = dropWhile (== '/') . dropWhileEnd (== '/')
72 trim = dropWhile (== '/') . dropWhileEnd (== '/')
74-- | All operations of a Swagger spec.
74-- | All operations of a Swagger spec.
75−allOperations :: Traversal' Swagger Operation
75+allOperations :: Traversal' OpenApi Operation
76allOperations = paths.traverse.template
76allOperations = paths.traverse.template
78-- | @'operationsOf' sub@ will traverse only those operations
78-- | @'operationsOf' sub@ will traverse only those operations
@@ -80,13 +80,13 @@ allOperations = paths.traverse.template
80-- by both path and method.
80-- by both path and method.
82-- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK"
82-- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK"
83−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
83+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
84−-- >>> let sub = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
84+-- >>> let sub = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
85-- >>> BSL.putStrLn $ encode api
85-- >>> BSL.putStrLn $ encode api
86-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
86-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
87-- >>> BSL.putStrLn $ encode $ api & operationsOf sub . at 404 ?~ "Not found"
87-- >>> BSL.putStrLn $ encode $ api & operationsOf sub . at 404 ?~ "Not found"
88-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"404":{"description":"Not found"},"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
88-- {"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
90operationsOf sub = paths.itraversed.withIndex.subops
90operationsOf sub = paths.itraversed.withIndex.subops
92 -- | Traverse operations that correspond to paths and methods of the sub API.
92 -- | Traverse operations that correspond to paths and methods of the sub API.
@@ -108,12 +108,12 @@ operationsOf sub = paths.itraversed.withIndex.subops
109-- 'applyTags' = 'applyTagsFor' 'allOperations'
109-- 'applyTags' = 'applyTagsFor' 'allOperations'
111−applyTags :: [Tag] -> Swagger -> Swagger
111+applyTags :: [Tag] -> OpenApi -> OpenApi
112applyTags = applyTagsFor allOperations
112applyTags = applyTagsFor allOperations
114-- | Apply tags to a part of Swagger spec and update the global
114-- | Apply tags to a part of Swagger spec and update the global
115-- list of tags.
115-- list of tags.
116−applyTagsFor :: Traversal' Swagger Operation -> [Tag] -> Swagger -> Swagger
116+applyTagsFor :: Traversal' OpenApi Operation -> [Tag] -> OpenApi -> OpenApi
117applyTagsFor ops ts swag = swag
117applyTagsFor ops ts swag = swag
118 & ops . tags %~ (<> InsOrdHS.fromList (map _tagName ts))
118 & ops . tags %~ (<> InsOrdHS.fromList (map _tagName ts))
119 & tags %~ (<> InsOrdHS.fromList ts)
119 & tags %~ (<> InsOrdHS.fromList ts)
@@ -141,13 +141,13 @@ declareResponse cType proxy = do
142-- Example:
142-- Example:
144−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
144+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
145-- >>> let res = declareResponse "application/json" (Proxy :: Proxy Day)
145-- >>> let res = declareResponse "application/json" (Proxy :: Proxy Day)
146-- >>> BSL.putStrLn $ encode $ api & setResponse 200 res
146-- >>> BSL.putStrLn $ encode $ api & setResponse 200 res
147-- {"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"}}}}
147-- {"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"}}}}
149-- See also @'setResponseWith'@.
149-- See also @'setResponseWith'@.
150−setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
150+setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
151setResponse = setResponseFor allOperations
151setResponse = setResponseFor allOperations
153-- | Set or update response for all operations.
153-- | Set or update response for all operations.
@@ -161,7 +161,7 @@ setResponse = setResponseFor allOperations
163-- See also @'setResponse'@.
163-- 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
165setResponseWith = setResponseForWith allOperations
165setResponseWith = setResponseForWith allOperations
167-- | Set response for specified operations.
167-- | Set response for specified operations.
@@ -170,7 +170,7 @@ setResponseWith = setResponseForWith allOperations
170-- If the response already exists it will be overwritten.
170-- If the response already exists it will be overwritten.
172-- See also @'setResponseForWith'@.
172-- 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
174setResponseFor ops code dres swag = swag
174setResponseFor ops code dres swag = swag
175 & components.schemas %~ (<> defs)
175 & components.schemas %~ (<> defs)
176 & ops . at code ?~ Inline res
176 & ops . at code ?~ Inline res
@@ -184,7 +184,7 @@ setResponseFor ops code dres swag = swag
184-- then just the new response is used.
184-- then just the new response is used.
186-- See also @'setResponseFor'@.
186-- 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
188setResponseForWith ops f code dres swag = swag
188setResponseForWith ops f code dres swag = swag
189 & components.schemas %~ (<> defs)
189 & components.schemas %~ (<> defs)
190 & ops . at code %~ Just . Inline . combine
190 & ops . at code %~ Just . Inline . combine