git.iko.soy/typeable/swagger2
on master help sign in
Outline swagger data model
commit16a4c0d5b8dc35b543080672ea724a84ce64443b authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateFri 6 Nov 2015, 16:30 (11 years ago) parent38c461a
2 files changed+151
src/Data/Swagger/Internal.hs+148 swagger2.cabal+3
src/Data/Swagger/Internal.hs+148
@@ -1 +1,149 @@
11module Data.Swagger.Internal where
2+
3+import Data.Text (Text)
4+import Network (HostName, PortNumber)
5+import Network.HTTP.Media (MediaType)
6+
7+-- | This is the root document object for the API specification.
8+data Swagger = Swagger
9+ { -- | Provides metadata about the API.
10+ -- The metadata can be used by the clients if needed.
11+ swaggerInfo :: SwaggerInfo
12+
13+ -- | The host (name or ip) serving the API. It MAY include a port.
14+ -- If the host is not included, the host serving the documentation is to be used (including the port).
15+ , swaggerHost :: Maybe SwaggerHost
16+
17+ -- | The base path on which the API is served, which is relative to the host.
18+ -- If it is not included, the API is served directly under the host.
19+ -- The value MUST start with a leading slash (/).
20+ , swaggerBasePath :: Maybe FilePath
21+
22+ -- | The transfer protocol of the API.
23+ -- If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
24+ , swaggerSchemes :: Maybe [SwaggerScheme]
25+
26+ -- | A list of MIME types the APIs can consume.
27+ -- This is global to all APIs but can be overridden on specific API calls.
28+ , swaggerConsumes :: [MediaType]
29+
30+ -- | A list of MIME types the APIs can produce.
31+ -- This is global to all APIs but can be overridden on specific API calls.
32+ , swaggerProduces :: [MediaType]
33+
34+ -- | The available paths and operations for the API.
35+ , swaggerPaths :: SwaggerPaths
36+
37+ -- | An object to hold data types produced and consumed by operations.
38+ , swaggerDefinitions :: [SwaggerDefinition]
39+
40+ -- | An object to hold parameters that can be used across operations.
41+ -- This property does not define global parameters for all operations.
42+ , swaggerParameters :: [SwaggerParamDefinition]
43+
44+ -- | An object to hold responses that can be used across operations.
45+ -- This property does not define global responses for all operations.
46+ , swaggerResponses :: [SwaggerResponseDefinition]
47+
48+ -- | Security scheme definitions that can be used across the specification.
49+ , swaggerSecurityDefinitions :: [SwaggerSecurityDefinition]
50+
51+ -- | A declaration of which security schemes are applied for the API as a whole.
52+ -- The list of values describes alternative security schemes that can be used
53+ -- (that is, there is a logical OR between the security requirements).
54+ -- Individual operations can override this definition.
55+ , swaggerSecurity :: [SwaggerSecurityRequirement]
56+
57+ -- | A list of tags used by the specification with additional metadata.
58+ -- The order of the tags can be used to reflect on their order by the parsing tools.
59+ -- Not all tags that are used by the Operation Object must be declared.
60+ -- The tags that are not declared may be organized randomly or based on the tools' logic.
61+ -- Each tag name in the list MUST be unique.
62+ , swaggerTags :: [SwaggerTag]
63+
64+ -- | Additional external documentation.
65+ , swaggerExternalDocs :: SwaggerExternalDocs
66+ } deriving (Show)
67+
68+-- | The object provides metadata about the API.
69+-- The metadata can be used by the clients if needed,
70+-- and can be presented in the Swagger-UI for convenience.
71+data SwaggerInfo = SwaggerInfo
72+ { -- | The title of the application.
73+ swaggerInfoTitle :: Text
74+
75+ -- | A short description of the application.
76+ -- GFM syntax can be used for rich text representation.
77+ , swaggerInfoDescription :: Maybe Text
78+
79+ -- | The Terms of Service for the API.
80+ , swaggerInfoTermsOfService :: Maybe Text
81+
82+ -- | The contact information for the exposed API.
83+ , swaggerInfoContact :: Maybe SwaggerContact
84+
85+ -- | The license information for the exposed API.
86+ , swaggerInfoLicense :: Maybe SwaggerLicense
87+
88+ -- | Provides the version of the application API
89+ -- (not to be confused with the specification version).
90+ , swaggerInfoVersion :: Text
91+ } deriving (Show)
92+
93+data SwaggerContact = SwaggerContact
94+ deriving (Show)
95+
96+data SwaggerLicense = SwaggerLicense
97+ deriving (Show)
98+
99+-- | The host (name or ip) serving the API. It MAY include a port.
100+data SwaggerHost = SwaggerHost
101+ { swaggerHostName :: HostName -- ^ Host name.
102+ , swaggerHostPort :: Maybe PortNumber -- ^ Optional port.
103+ } deriving (Show)
104+
105+-- | The transfer protocol of the API.
106+data SwaggerScheme
107+ = Http
108+ | Https
109+ | Ws
110+ | Wss
111+ deriving (Show)
112+
113+-- | The available paths and operations for the API.
114+data SwaggerPaths = SwaggerPaths
115+ { -- | Holds the relative paths to the individual endpoints.
116+ -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
117+ swaggerPathsMap :: [SwaggerPath]
118+
119+ -- | Allows extensions to the Swagger Schema.
120+ , swaggerPathsExtensions :: [SwaggerExtension]
121+ } deriving (Show)
122+
123+data SwaggerPath = SwaggerPath
124+ deriving (Show)
125+
126+data SwaggerExtension = SwaggerExtension
127+ deriving (Show)
128+
129+data SwaggerDefinition = SwaggerDefinition
130+ deriving (Show)
131+
132+data SwaggerParamDefinition = SwaggerParamDefinition
133+ deriving (Show)
134+
135+data SwaggerResponseDefinition = SwaggerResponseDefinition
136+ deriving (Show)
137+
138+data SwaggerSecurityDefinition = SwaggerSecurityDefinition
139+ deriving (Show)
140+
141+data SwaggerSecurityRequirement = SwaggerSecurityRequirement
142+ deriving (Show)
143+
144+data SwaggerTag = SwaggerTag
145+ deriving (Show)
146+
147+data SwaggerExternalDocs = SwaggerExternalDocs
148+ deriving (Show)
149+
swagger2.cabal+3
@@ -21,6 +21,9 @@ library
2121 Data.Swagger.Internal
2222 build-depends: base >= 4.7 && < 5
2323 , aeson
24+ , http-media
25+ , network
26+ , text
2427 default-language: Haskell2010
2528
2629source-repository head