Skip to content

Commit c0feab6

Browse files
committed
Rename Swagger -> OpenApi
1 parent 4439809 commit c0feab6

File tree

13 files changed

+139
-138
lines changed

13 files changed

+139
-138
lines changed

servant-openapi3.cabal

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ custom-setup
5959
library
6060
ghc-options: -Wall
6161
exposed-modules:
62-
Servant.Swagger
63-
Servant.Swagger.Test
64-
Servant.Swagger.TypeLevel
62+
Servant.OpenApi
63+
Servant.OpenApi.Test
64+
Servant.OpenApi.TypeLevel
6565

6666
-- Internal modules
67-
Servant.Swagger.Internal
68-
Servant.Swagger.Internal.Orphans
69-
Servant.Swagger.Internal.Test
70-
Servant.Swagger.Internal.TypeLevel
71-
Servant.Swagger.Internal.TypeLevel.API
72-
Servant.Swagger.Internal.TypeLevel.Every
73-
Servant.Swagger.Internal.TypeLevel.TMap
67+
Servant.OpenApi.Internal
68+
Servant.OpenApi.Internal.Orphans
69+
Servant.OpenApi.Internal.Test
70+
Servant.OpenApi.Internal.TypeLevel
71+
Servant.OpenApi.Internal.TypeLevel.API
72+
Servant.OpenApi.Internal.TypeLevel.Every
73+
Servant.OpenApi.Internal.TypeLevel.TMap
7474
hs-source-dirs: src
7575
build-depends: aeson >=1.4.2.0 && <1.6
7676
, aeson-pretty >=0.8.7 && <0.9
@@ -126,5 +126,5 @@ test-suite spec
126126
, time
127127
, vector
128128
other-modules:
129-
Servant.SwaggerSpec
129+
Servant.OpenApiSpec
130130
default-language: Haskell2010

src/Servant/Swagger.hs renamed to src/Servant/OpenApi.hs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
-- |
2-
-- Module: Servant.Swagger
2+
-- Module: Servant.OpenApi
33
-- License: BSD3
44
-- Maintainer: Nickolay Kudasov <[email protected]>
55
-- Stability: experimental
66
--
77
-- This module provides means to generate and manipulate
8-
-- Swagger specification for servant APIs.
8+
-- OpenApi specification for servant APIs.
99
--
10-
-- Swagger is a project used to describe and document RESTful APIs.
10+
-- OpenApi is a project used to describe and document RESTful APIs.
1111
--
12-
-- The Swagger specification defines a set of files required to describe such an API.
13-
-- These files can then be used by the Swagger-UI project to display the API
14-
-- and Swagger-Codegen to generate clients in various languages.
12+
-- The OpenApi specification defines a set of files required to describe such an API.
13+
-- These files can then be used by the OpenApi-UI project to display the API
14+
-- and OpenApi-Codegen to generate clients in various languages.
1515
-- Additional utilities can also take advantage of the resulting files, such as testing tools.
1616
--
17-
-- For more information see <http://swagger.io/ Swagger documentation>.
18-
module Servant.Swagger (
17+
-- For more information see <http://swagger.io/ OpenApi documentation>.
18+
module Servant.OpenApi (
1919
-- * How to use this library
2020
-- $howto
2121

22-
-- ** Generate @'Swagger'@
22+
-- ** Generate @'OpenApi'@
2323
-- $generate
2424

2525
-- ** Annotate
@@ -31,8 +31,8 @@ module Servant.Swagger (
3131
-- ** Serve
3232
-- $serve
3333

34-
-- * @'HasSwagger'@ class
35-
HasSwagger(..),
34+
-- * @'HasOpenApi'@ class
35+
HasOpenApi(..),
3636

3737
-- * Manipulation
3838
subOperations,
@@ -42,9 +42,9 @@ module Servant.Swagger (
4242
validateEveryToJSONWithPatternChecker,
4343
) where
4444

45-
import Servant.Swagger.Internal
46-
import Servant.Swagger.Test
47-
import Servant.Swagger.Internal.Orphans ()
45+
import Servant.OpenApi.Internal
46+
import Servant.OpenApi.Test
47+
import Servant.OpenApi.Internal.Orphans ()
4848

4949
-- $setup
5050
-- >>> import Control.Applicative
@@ -76,7 +76,7 @@ import Servant.Swagger.Internal.Orphans ()
7676

7777
-- $howto
7878
--
79-
-- This section explains how to use this library to generate Swagger specification,
79+
-- This section explains how to use this library to generate OpenApi specification,
8080
-- modify it and run automatic tests for a servant API.
8181
--
8282
-- For the purposes of this section we will use this servant API:
@@ -96,24 +96,24 @@ import Servant.Swagger.Internal.Orphans ()
9696
-- @GetUser@ returns a user given his\/her ID. @PostUser@ creates a new user and returns his\/her ID.
9797

9898
-- $generate
99-
-- In order to generate @'Swagger'@ specification for a servant API, just use @'toSwagger'@:
99+
-- In order to generate @'OpenApi'@ specification for a servant API, just use @'toOpenApi'@:
100100
--
101-
-- >>> BSL8.putStrLn $ encode $ toSwagger (Proxy :: Proxy UserAPI)
101+
-- >>> BSL8.putStrLn $ encode $ toOpenApi (Proxy :: Proxy UserAPI)
102102
-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/":{"get":{"responses":{"200":{"content":{"application/json;charset=utf-8":{"schema":{"items":{"$ref":"#/components/schemas/User"},"type":"array"}}},"description":""}}},"post":{"requestBody":{"content":{"application/json;charset=utf-8":{"schema":{"$ref":"#/components/schemas/User"}}}},"responses":{"400":{"description":"Invalid `body`"},"200":{"content":{"application/json;charset=utf-8":{"schema":{"$ref":"#/components/schemas/UserId"}}},"description":""}}}},"/{user_id}":{"get":{"parameters":[{"required":true,"schema":{"type":"integer"},"in":"path","name":"user_id"}],"responses":{"404":{"description":"`user_id` not found"},"200":{"content":{"application/json;charset=utf-8":{"schema":{"$ref":"#/components/schemas/User"}}},"description":""}}}}},"components":{"schemas":{"User":{"required":["name","age"],"type":"object","properties":{"age":{"maximum":9223372036854775807,"minimum":-9223372036854775808,"type":"integer"},"name":{"type":"string"}}},"UserId":{"type":"integer"}}}}
103103
--
104-
-- By default @'toSwagger'@ will generate specification for all API routes, parameters, headers, responses and data schemas.
104+
-- By default @'toOpenApi'@ will generate specification for all API routes, parameters, headers, responses and data schemas.
105105
--
106106
-- For some parameters it will also add 400 and/or 404 responses with a description mentioning parameter name.
107107
--
108108
-- Data schemas come from @'ToParamSchema'@ and @'ToSchema'@ classes.
109109

110110
-- $annotate
111-
-- While initially generated @'Swagger'@ looks good, it lacks some information it can't get from a servant API.
111+
-- While initially generated @'OpenApi'@ looks good, it lacks some information it can't get from a servant API.
112112
--
113-
-- We can add this information using field lenses from @"Data.Swagger"@:
113+
-- We can add this information using field lenses from @"Data.OpenApi"@:
114114
--
115115
-- >>> :{
116-
-- BSL8.putStrLn $ encode $ toSwagger (Proxy :: Proxy UserAPI)
116+
-- BSL8.putStrLn $ encode $ toOpenApi (Proxy :: Proxy UserAPI)
117117
-- & info.title .~ "User API"
118118
-- & info.version .~ "1.0"
119119
-- & info.description ?~ "This is an API for the Users service"
@@ -128,13 +128,13 @@ import Servant.Swagger.Internal.Orphans ()
128128
-- @'subOperations' sub api@ traverses all operations of the @api@ which are also present in @sub@.
129129
-- Furthermore, @sub@ is required to be an exact sub API of @api. Otherwise it will not typecheck.
130130
--
131-
-- @"Data.Swagger.Operation"@ provides some useful helpers that can be used with @'subOperations'@.
131+
-- @"Data.OpenApi.Operation"@ provides some useful helpers that can be used with @'subOperations'@.
132132
-- One example is applying tags to certain endpoints:
133133
--
134134
-- >>> let getOps = subOperations (Proxy :: Proxy (GetUsers :<|> GetUser)) (Proxy :: Proxy UserAPI)
135135
-- >>> let postOps = subOperations (Proxy :: Proxy PostUser) (Proxy :: Proxy UserAPI)
136136
-- >>> :{
137-
-- BSL8.putStrLn $ encode $ toSwagger (Proxy :: Proxy UserAPI)
137+
-- BSL8.putStrLn $ encode $ toOpenApi (Proxy :: Proxy UserAPI)
138138
-- & applyTagsFor getOps ["get" & description ?~ "GET operations"]
139139
-- & applyTagsFor postOps ["post" & description ?~ "POST operations"]
140140
-- :}
@@ -170,7 +170,7 @@ import Servant.Swagger.Internal.Orphans ()
170170
-- Although servant is great, chances are that your API clients don't use Haskell.
171171
-- In many cases @swagger.json@ serves as a specification, not a Haskell type.
172172
--
173-
-- In this cases it is a good idea to store generated and annotated @'Swagger'@ in a @swagger.json@ file
173+
-- In this cases it is a good idea to store generated and annotated @'OpenApi'@ in a @swagger.json@ file
174174
-- under a version control system (such as Git, Subversion, Mercurial, etc.).
175175
--
176176
-- It is also recommended to version API based on changes to the @swagger.json@ rather than changes
@@ -179,6 +179,6 @@ import Servant.Swagger.Internal.Orphans ()
179179
-- See <example/test/TodoSpec.hs TodoSpec.hs> for an example of a complete test suite for a swagger specification.
180180

181181
-- $serve
182-
-- If you're implementing a server for an API, you might also want to serve its @'Swagger'@ specification.
182+
-- If you're implementing a server for an API, you might also want to serve its @'OpenApi'@ specification.
183183
--
184184
-- See <example/src/Todo.hs Todo.hs> for an example of a server.

0 commit comments

Comments
 (0)