git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #9 from GetShopTV/no-swagger-prefix
9723dd1Nickolay Kudasov
src/Data/Swagger.hs+40−40
@@ -8,74 +8,74 @@
8module Data.Swagger (
8module Data.Swagger (
9 -- * Swagger specification
9 -- * Swagger specification
10 Swagger(..),
10 Swagger(..),
11− SwaggerHost(..),
11+ Host(..),
12− SwaggerScheme(..),
12+ Scheme(..),
13
13
14 -- * Info types
14 -- * Info types
15− SwaggerInfo(..),
15+ Info(..),
16− SwaggerContact(..),
16+ Contact(..),
17− SwaggerLicense(..),
17+ License(..),
18
18
19 -- * Paths
19 -- * Paths
20− SwaggerPaths(..),
20+ Paths(..),
21− SwaggerPathItem(..),
21+ PathItem(..),
22
22
23 -- * Operations
23 -- * Operations
24− SwaggerTag(..),
24+ Tag(..),
25− SwaggerOperation(..),
25+ Operation(..),
26
26
27 -- * Types and formats
27 -- * Types and formats
28− SwaggerParameterType(..),
28+ ParameterType(..),
29− SwaggerItemsType(..),
29+ ItemsType(..),
30− SwaggerSchemaType(..),
30+ SchemaType(..),
31− SwaggerFormat(..),
31+ Format(..),
32− SwaggerCollectionFormat(..),
32+ CollectionFormat(..),
33− SwaggerItemsCollectionFormat(..),
33+ ItemsCollectionFormat(..),
34
34
35 -- * Parameters
35 -- * Parameters
36− SwaggerParameter(..),
36+ Parameter(..),
37− SwaggerParameterSchema(..),
37+ ParameterSchema(..),
38− SwaggerParameterOtherSchema(..),
38+ ParameterOtherSchema(..),
39− SwaggerParameterLocation(..),
39+ ParameterLocation(..),
40− SwaggerParamName(..),
40+ ParamName(..),
41− SwaggerItems(..),
41+ Items(..),
42− SwaggerHeader(..),
42+ Header(..),
43− SwaggerExample(..),
43+ Example(..),
44
44
45 -- * Schema
45 -- * Schema
46− SwaggerSchema(..),
46+ Schema(..),
47− SwaggerSchemaItems(..),
47+ SchemaItems(..),
48− SwaggerSchemaCommon(..),
48+ SchemaCommon(..),
49− SwaggerXml(..),
49+ Xml(..),
50
50
51 -- * Responses
51 -- * Responses
52− SwaggerResponses(..),
52+ Responses(..),
53− SwaggerResponse(..),
53+ Response(..),
54
54
55 -- * Security
55 -- * Security
56− SwaggerSecurityScheme(..),
56+ SecurityScheme(..),
57− SwaggerSecuritySchemeType(..),
57+ SecuritySchemeType(..),
58− SwaggerSecurityRequirement(..),
58+ SecurityRequirement(..),
59
59
60 -- ** API key
60 -- ** API key
61− SwaggerApiKeyParams(..),
61+ ApiKeyParams(..),
62− SwaggerApiKeyLocation(..),
62+ ApiKeyLocation(..),
63
63
64 -- ** OAuth2
64 -- ** OAuth2
65− SwaggerOAuth2Params(..),
65+ OAuth2Params(..),
66− SwaggerOAuth2Flow(..),
66+ OAuth2Flow(..),
67 AuthorizationURL(..),
67 AuthorizationURL(..),
68 TokenURL(..),
68 TokenURL(..),
69
69
70 -- * External documentation
70 -- * External documentation
71− SwaggerExternalDocs(..),
71+ ExternalDocs(..),
72
72
73 -- * References
73 -- * References
74− SwaggerReference(..),
74+ Reference(..),
75− SwaggerReferenced(..),
75+ Referenced(..),
76
76
77 -- * Miscellaneous
77 -- * Miscellaneous
78− SwaggerMimeList(..),
78+ MimeList(..),
79 URL(..),
79 URL(..),
80) where
80) where
81
81
src/Data/Swagger/Internal.hs+406−406
@@ -35,117 +35,117 @@ import Data.Swagger.Internal.Utils
35data Swagger = Swagger
35data Swagger = Swagger
36 { -- | Provides metadata about the API.
36 { -- | Provides metadata about the API.
37 -- The metadata can be used by the clients if needed.
37 -- The metadata can be used by the clients if needed.
38− _swaggerInfo :: SwaggerInfo
38+ _info :: Info
39
39
40 -- | The host (name or ip) serving the API. It MAY include a port.
40 -- | The host (name or ip) serving the API. It MAY include a port.
41 -- If the host is not included, the host serving the documentation is to be used (including the port).
41 -- If the host is not included, the host serving the documentation is to be used (including the port).
42− , _swaggerHost :: Maybe SwaggerHost
42+ , _host :: Maybe Host
43
43
44 -- | The base path on which the API is served, which is relative to the host.
44 -- | The base path on which the API is served, which is relative to the host.
45 -- If it is not included, the API is served directly under the host.
45 -- If it is not included, the API is served directly under the host.
46 -- The value MUST start with a leading slash (/).
46 -- The value MUST start with a leading slash (/).
47− , _swaggerBasePath :: Maybe FilePath
47+ , _basePath :: Maybe FilePath
48
48
49 -- | The transfer protocol of the API.
49 -- | The transfer protocol of the API.
50 -- If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
50 -- If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
51− , _swaggerSchemes :: Maybe [SwaggerScheme]
51+ , _schemes :: Maybe [Scheme]
52
52
53 -- | A list of MIME types the APIs can consume.
53 -- | A list of MIME types the APIs can consume.
54 -- This is global to all APIs but can be overridden on specific API calls.
54 -- This is global to all APIs but can be overridden on specific API calls.
55− , _swaggerConsumes :: SwaggerMimeList
55+ , _consumes :: MimeList
56
56
57 -- | A list of MIME types the APIs can produce.
57 -- | A list of MIME types the APIs can produce.
58 -- This is global to all APIs but can be overridden on specific API calls.
58 -- This is global to all APIs but can be overridden on specific API calls.
59− , _swaggerProduces :: SwaggerMimeList
59+ , _produces :: MimeList
60
60
61 -- | The available paths and operations for the API.
61 -- | The available paths and operations for the API.
62− , _swaggerPaths :: SwaggerPaths
62+ , _paths :: Paths
63
63
64 -- | An object to hold data types produced and consumed by operations.
64 -- | An object to hold data types produced and consumed by operations.
65− , _swaggerDefinitions :: HashMap Text SwaggerSchema
65+ , _definitions :: HashMap Text Schema
66
66
67 -- | An object to hold parameters that can be used across operations.
67 -- | An object to hold parameters that can be used across operations.
68 -- This property does not define global parameters for all operations.
68 -- This property does not define global parameters for all operations.
69− , _swaggerParameters :: HashMap Text SwaggerParameter
69+ , _parameters :: HashMap Text Parameter
70
70
71 -- | An object to hold responses that can be used across operations.
71 -- | An object to hold responses that can be used across operations.
72 -- This property does not define global responses for all operations.
72 -- This property does not define global responses for all operations.
73− , _swaggerResponses :: HashMap Text SwaggerResponse
73+ , _responses :: HashMap Text Response
74
74
75 -- | Security scheme definitions that can be used across the specification.
75 -- | Security scheme definitions that can be used across the specification.
76− , _swaggerSecurityDefinitions :: HashMap Text SwaggerSecurityScheme
76+ , _securityDefinitions :: HashMap Text SecurityScheme
77
77
78 -- | A declaration of which security schemes are applied for the API as a whole.
78 -- | A declaration of which security schemes are applied for the API as a whole.
79 -- The list of values describes alternative security schemes that can be used
79 -- The list of values describes alternative security schemes that can be used
80 -- (that is, there is a logical OR between the security requirements).
80 -- (that is, there is a logical OR between the security requirements).
81 -- Individual operations can override this definition.
81 -- Individual operations can override this definition.
82− , _swaggerSecurity :: [SwaggerSecurityRequirement]
82+ , _security :: [SecurityRequirement]
83
83
84 -- | A list of tags used by the specification with additional metadata.
84 -- | A list of tags used by the specification with additional metadata.
85 -- The order of the tags can be used to reflect on their order by the parsing tools.
85 -- The order of the tags can be used to reflect on their order by the parsing tools.
86 -- Not all tags that are used by the Operation Object must be declared.
86 -- Not all tags that are used by the Operation Object must be declared.
87 -- The tags that are not declared may be organized randomly or based on the tools' logic.
87 -- The tags that are not declared may be organized randomly or based on the tools' logic.
88 -- Each tag name in the list MUST be unique.
88 -- Each tag name in the list MUST be unique.
89− , _swaggerTags :: [SwaggerTag]
89+ , _tags :: [Tag]
90
90
91 -- | Additional external documentation.
91 -- | Additional external documentation.
92− , _swaggerExternalDocs :: Maybe SwaggerExternalDocs
92+ , _externalDocs :: Maybe ExternalDocs
93 } deriving (Eq, Show, Generic)
93 } deriving (Eq, Show, Generic)
94
94
95-- | The object provides metadata about the API.
95-- | The object provides metadata about the API.
96-- The metadata can be used by the clients if needed,
96-- The metadata can be used by the clients if needed,
97-- and can be presented in the Swagger-UI for convenience.
97-- and can be presented in the Swagger-UI for convenience.
98−data SwaggerInfo = SwaggerInfo
98+data Info = Info
99 { -- | The title of the application.
99 { -- | The title of the application.
100− _swaggerInfoTitle :: Text
100+ _infoTitle :: Text
101
101
102 -- | A short description of the application.
102 -- | A short description of the application.
103 -- GFM syntax can be used for rich text representation.
103 -- GFM syntax can be used for rich text representation.
104− , _swaggerInfoDescription :: Maybe Text
104+ , _infoDescription :: Maybe Text
105
105
106 -- | The Terms of Service for the API.
106 -- | The Terms of Service for the API.
107− , _swaggerInfoTermsOfService :: Maybe Text
107+ , _infoTermsOfService :: Maybe Text
108
108
109 -- | The contact information for the exposed API.
109 -- | The contact information for the exposed API.
110− , _swaggerInfoContact :: Maybe SwaggerContact
110+ , _infoContact :: Maybe Contact
111
111
112 -- | The license information for the exposed API.
112 -- | The license information for the exposed API.
113− , _swaggerInfoLicense :: Maybe SwaggerLicense
113+ , _infoLicense :: Maybe License
114
114
115 -- | Provides the version of the application API
115 -- | Provides the version of the application API
116 -- (not to be confused with the specification version).
116 -- (not to be confused with the specification version).
117− , _swaggerInfoVersion :: Text
117+ , _infoVersion :: Text
118 } deriving (Eq, Show, Generic)
118 } deriving (Eq, Show, Generic)
119
119
120-- | Contact information for the exposed API.
120-- | Contact information for the exposed API.
121−data SwaggerContact = SwaggerContact
121+data Contact = Contact
122 { -- | The identifying name of the contact person/organization.
122 { -- | The identifying name of the contact person/organization.
123− _swaggerContactName :: Maybe Text
123+ _contactName :: Maybe Text
124
124
125 -- | The URL pointing to the contact information.
125 -- | The URL pointing to the contact information.
126− , _swaggerContactUrl :: Maybe URL
126+ , _contactUrl :: Maybe URL
127
127
128 -- | The email address of the contact person/organization.
128 -- | The email address of the contact person/organization.
129− , _swaggerContactEmail :: Maybe Text
129+ , _contactEmail :: Maybe Text
130 } deriving (Eq, Show)
130 } deriving (Eq, Show)
131
131
132-- | License information for the exposed API.
132-- | License information for the exposed API.
133−data SwaggerLicense = SwaggerLicense
133+data License = License
134 { -- | The license name used for the API.
134 { -- | The license name used for the API.
135− _swaggerLicenseName :: Text
135+ _licenseName :: Text
136
136
137 -- | A URL to the license used for the API.
137 -- | A URL to the license used for the API.
138− , _swaggerLicenseUrl :: Maybe URL
138+ , _licenseUrl :: Maybe URL
139 } deriving (Eq, Show)
139 } deriving (Eq, Show)
140
140
141-- | The host (name or ip) serving the API. It MAY include a port.
141-- | The host (name or ip) serving the API. It MAY include a port.
142−data SwaggerHost = SwaggerHost
142+data Host = Host
143− { _swaggerHostName :: HostName -- ^ Host name.
143+ { _hostName :: HostName -- ^ Host name.
144− , _swaggerHostPort :: Maybe PortNumber -- ^ Optional port.
144+ , _hostPort :: Maybe PortNumber -- ^ Optional port.
145 } deriving (Eq, Show)
145 } deriving (Eq, Show)
146
146
147-- | The transfer protocol of the API.
147-- | The transfer protocol of the API.
148−data SwaggerScheme
148+data Scheme
149 = Http
149 = Http
150 | Https
150 | Https
151 | Ws
151 | Ws
@@ -153,305 +153,305 @@ data SwaggerScheme
153 deriving (Eq, Show)
153 deriving (Eq, Show)
154
154
155-- | The available paths and operations for the API.
155-- | The available paths and operations for the API.
156−data SwaggerPaths = SwaggerPaths
156+data Paths = Paths
157 { -- | Holds the relative paths to the individual endpoints.
157 { -- | Holds the relative paths to the individual endpoints.
158− -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
158+ -- The path is appended to the @'basePath'@ in order to construct the full URL.
159− _swaggerPathsMap :: HashMap FilePath SwaggerPathItem
159+ _pathsMap :: HashMap FilePath PathItem
160 } deriving (Eq, Show, Generic)
160 } deriving (Eq, Show, Generic)
161
161
162-- | Describes the operations available on a single path.
162-- | Describes the operations available on a single path.
163−-- A @'SwaggerPathItem'@ may be empty, due to ACL constraints.
163+-- A @'PathItem'@ may be empty, due to ACL constraints.
164-- The path itself is still exposed to the documentation viewer
164-- The path itself is still exposed to the documentation viewer
165-- but they will not know which operations and parameters are available.
165-- but they will not know which operations and parameters are available.
166−data SwaggerPathItem = SwaggerPathItem
166+data PathItem = PathItem
167 { -- | A definition of a GET operation on this path.
167 { -- | A definition of a GET operation on this path.
168− _swaggerPathItemGet :: Maybe SwaggerOperation
168+ _pathItemGet :: Maybe Operation
169
169
170 -- | A definition of a PUT operation on this path.
170 -- | A definition of a PUT operation on this path.
171− , _swaggerPathItemPut :: Maybe SwaggerOperation
171+ , _pathItemPut :: Maybe Operation
172
172
173 -- | A definition of a POST operation on this path.
173 -- | A definition of a POST operation on this path.
174− , _swaggerPathItemPost :: Maybe SwaggerOperation
174+ , _pathItemPost :: Maybe Operation
175
175
176 -- | A definition of a DELETE operation on this path.
176 -- | A definition of a DELETE operation on this path.
177− , _swaggerPathItemDelete :: Maybe SwaggerOperation
177+ , _pathItemDelete :: Maybe Operation
178
178
179 -- | A definition of a OPTIONS operation on this path.
179 -- | A definition of a OPTIONS operation on this path.
180− , _swaggerPathItemOptions :: Maybe SwaggerOperation
180+ , _pathItemOptions :: Maybe Operation
181
181
182 -- | A definition of a HEAD operation on this path.
182 -- | A definition of a HEAD operation on this path.
183− , _swaggerPathItemHead :: Maybe SwaggerOperation
183+ , _pathItemHead :: Maybe Operation
184
184
185 -- | A definition of a PATCH operation on this path.
185 -- | A definition of a PATCH operation on this path.
186− , _swaggerPathItemPatch :: Maybe SwaggerOperation
186+ , _pathItemPatch :: Maybe Operation
187
187
188 -- | A list of parameters that are applicable for all the operations described under this path.
188 -- | A list of parameters that are applicable for all the operations described under this path.
189 -- These parameters can be overridden at the operation level, but cannot be removed there.
189 -- These parameters can be overridden at the operation level, but cannot be removed there.
190 -- The list MUST NOT include duplicated parameters.
190 -- The list MUST NOT include duplicated parameters.
191 -- A unique parameter is defined by a combination of a name and location.
191 -- A unique parameter is defined by a combination of a name and location.
192− , _swaggerPathItemParameters :: [SwaggerReferenced SwaggerParameter]
192+ , _pathItemParameters :: [Referenced Parameter]
193 } deriving (Eq, Show, Generic)
193 } deriving (Eq, Show, Generic)
194
194
195-- | Describes a single API operation on a path.
195-- | Describes a single API operation on a path.
196−data SwaggerOperation = SwaggerOperation
196+data Operation = Operation
197 { -- | A list of tags for API documentation control.
197 { -- | A list of tags for API documentation control.
198 -- Tags can be used for logical grouping of operations by resources or any other qualifier.
198 -- Tags can be used for logical grouping of operations by resources or any other qualifier.
199− _swaggerOperationTags :: [Text]
199+ _operationTags :: [Text]
200
200
201 -- | A short summary of what the operation does.
201 -- | A short summary of what the operation does.
202 -- For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
202 -- For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
203− , _swaggerOperationSummary :: Maybe Text
203+ , _operationSummary :: Maybe Text
204
204
205 -- | A verbose explanation of the operation behavior.
205 -- | A verbose explanation of the operation behavior.
206 -- GFM syntax can be used for rich text representation.
206 -- GFM syntax can be used for rich text representation.
207− , _swaggerOperationDescription :: Maybe Text
207+ , _operationDescription :: Maybe Text
208
208
209 -- | Additional external documentation for this operation.
209 -- | Additional external documentation for this operation.
210− , _swaggerOperationExternalDocs :: Maybe SwaggerExternalDocs
210+ , _operationExternalDocs :: Maybe ExternalDocs
211
211
212 -- | Unique string used to identify the operation.
212 -- | Unique string used to identify the operation.
213 -- The id MUST be unique among all operations described in the API.
213 -- The id MUST be unique among all operations described in the API.
214 -- Tools and libraries MAY use the it to uniquely identify an operation,
214 -- Tools and libraries MAY use the it to uniquely identify an operation,
215 -- therefore, it is recommended to follow common programming naming conventions.
215 -- therefore, it is recommended to follow common programming naming conventions.
216− , _swaggerOperationOperationId :: Maybe Text
216+ , _operationOperationId :: Maybe Text
217
217
218 -- | A list of MIME types the operation can consume.
218 -- | A list of MIME types the operation can consume.
219− -- This overrides the @'swaggerConsumes'@.
219+ -- This overrides the @'consumes'@.
220 -- @Just []@ MAY be used to clear the global definition.
220 -- @Just []@ MAY be used to clear the global definition.
221− , _swaggerOperationConsumes :: Maybe SwaggerMimeList
221+ , _operationConsumes :: Maybe MimeList
222
222
223 -- | A list of MIME types the operation can produce.
223 -- | A list of MIME types the operation can produce.
224− -- This overrides the @'swaggerProduces'@.
224+ -- This overrides the @'produces'@.
225 -- @Just []@ MAY be used to clear the global definition.
225 -- @Just []@ MAY be used to clear the global definition.
226− , _swaggerOperationProduces :: Maybe SwaggerMimeList
226+ , _operationProduces :: Maybe MimeList
227
227
228 -- | A list of parameters that are applicable for this operation.
228 -- | A list of parameters that are applicable for this operation.
229− -- If a parameter is already defined at the @'SwaggerPathItem'@,
229+ -- If a parameter is already defined at the @'PathItem'@,
230 -- the new definition will override it, but can never remove it.
230 -- the new definition will override it, but can never remove it.
231 -- The list MUST NOT include duplicated parameters.
231 -- The list MUST NOT include duplicated parameters.
232 -- A unique parameter is defined by a combination of a name and location.
232 -- A unique parameter is defined by a combination of a name and location.
233− , _swaggerOperationParameters :: [SwaggerReferenced SwaggerParameter]
233+ , _operationParameters :: [Referenced Parameter]
234
234
235 -- | The list of possible responses as they are returned from executing this operation.
235 -- | The list of possible responses as they are returned from executing this operation.
236− , _swaggerOperationResponses :: SwaggerResponses
236+ , _operationResponses :: Responses
237
237
238 -- | The transfer protocol for the operation.
238 -- | The transfer protocol for the operation.
239− -- The value overrides @'swaggerSchemes'@.
239+ -- The value overrides @'schemes'@.
240− , _swaggerOperationSchemes :: Maybe [SwaggerScheme]
240+ , _operationSchemes :: Maybe [Scheme]
241
241
242 -- | Declares this operation to be deprecated.
242 -- | Declares this operation to be deprecated.
243 -- Usage of the declared operation should be refrained.
243 -- Usage of the declared operation should be refrained.
244 -- Default value is @False@.
244 -- Default value is @False@.
245− , _swaggerOperationDeprecated :: Maybe Bool
245+ , _operationDeprecated :: Maybe Bool
246
246
247 -- | A declaration of which security schemes are applied for this operation.
247 -- | A declaration of which security schemes are applied for this operation.
248 -- The list of values describes alternative security schemes that can be used
248 -- The list of values describes alternative security schemes that can be used
249 -- (that is, there is a logical OR between the security requirements).
249 -- (that is, there is a logical OR between the security requirements).
250 -- This definition overrides any declared top-level security.
250 -- This definition overrides any declared top-level security.
251 -- To remove a top-level security declaration, @Just []@ can be used.
251 -- To remove a top-level security declaration, @Just []@ can be used.
252− , _swaggerOperationSecurity :: [SwaggerSecurityRequirement]
252+ , _operationSecurity :: [SecurityRequirement]
253 } deriving (Eq, Show, Generic)
253 } deriving (Eq, Show, Generic)
254
254
255−newtype SwaggerMimeList = SwaggerMimeList { getSwaggerMimeList :: [MediaType] }
255+newtype MimeList = MimeList { getMimeList :: [MediaType] }
256 deriving (Eq, Show, Monoid)
256 deriving (Eq, Show, Monoid)
257
257
258-- | Describes a single operation parameter.
258-- | Describes a single operation parameter.
259-- A unique parameter is defined by a combination of a name and location.
259-- A unique parameter is defined by a combination of a name and location.
260−data SwaggerParameter = SwaggerParameter
260+data Parameter = Parameter
261 { -- | The name of the parameter.
261 { -- | The name of the parameter.
262 -- Parameter names are case sensitive.
262 -- Parameter names are case sensitive.
263− _swaggerParameterName :: Text
263+ _parameterName :: Text
264
264
265 -- | A brief description of the parameter.
265 -- | A brief description of the parameter.
266 -- This could contain examples of use.
266 -- This could contain examples of use.
267 -- GFM syntax can be used for rich text representation.
267 -- GFM syntax can be used for rich text representation.
268− , _swaggerParameterDescription :: Maybe Text
268+ , _parameterDescription :: Maybe Text
269
269
270 -- | Determines whether this parameter is mandatory.
270 -- | Determines whether this parameter is mandatory.
271 -- If the parameter is in "path", this property is required and its value MUST be true.
271 -- If the parameter is in "path", this property is required and its value MUST be true.
272 -- Otherwise, the property MAY be included and its default value is @False@.
272 -- Otherwise, the property MAY be included and its default value is @False@.
273− , _swaggerParameterRequired :: Maybe Bool
273+ , _parameterRequired :: Maybe Bool
274
274
275 -- | Parameter schema.
275 -- | Parameter schema.
276− , _swaggerParameterSchema :: SwaggerParameterSchema
276+ , _parameterSchema :: ParameterSchema
277 } deriving (Eq, Show, Generic)
277 } deriving (Eq, Show, Generic)
278
278
279−data SwaggerParameterSchema
279+data ParameterSchema
280− = SwaggerParameterBody (SwaggerReferenced SwaggerSchema)
280+ = ParameterBody (Referenced Schema)
281− | SwaggerParameterOther SwaggerParameterOtherSchema
281+ | ParameterOther ParameterOtherSchema
282 deriving (Eq, Show)
282 deriving (Eq, Show)
283
283
284−data SwaggerParameterOtherSchema = SwaggerParameterOtherSchema
284+data ParameterOtherSchema = ParameterOtherSchema
285 { -- | The location of the parameter.
285 { -- | The location of the parameter.
286− _swaggerParameterOtherSchemaIn :: SwaggerParameterLocation
286+ _parameterOtherSchemaIn :: ParameterLocation
287
287
288 -- | The type of the parameter.
288 -- | The type of the parameter.
289 -- Since the parameter is not located at the request body,
289 -- Since the parameter is not located at the request body,
290 -- it is limited to simple types (that is, not an object).
290 -- it is limited to simple types (that is, not an object).
291− -- If type is @'SwaggerParamFile'@, the @consumes@ MUST be either
291+ -- If type is @'ParamFile'@, the @consumes@ MUST be either
292 -- "multipart/form-data" or " application/x-www-form-urlencoded"
292 -- "multipart/form-data" or " application/x-www-form-urlencoded"
293− -- and the parameter MUST be in @'SwaggerParameterFormData'@.
293+ -- and the parameter MUST be in @'ParameterFormData'@.
294− , _swaggerParameterOtherSchemaType :: SwaggerParameterType
294+ , _parameterOtherSchemaType :: ParameterType
295
295
296 -- | The extending format for the previously mentioned type.
296 -- | The extending format for the previously mentioned type.
297− , _swaggerParameterOtherSchemaFormat :: Maybe SwaggerFormat
297+ , _parameterOtherSchemaFormat :: Maybe Format
298
298
299 -- | Sets the ability to pass empty-valued parameters.
299 -- | Sets the ability to pass empty-valued parameters.
300− -- This is valid only for either @'SwaggerParameterQuery'@ or @'SwaggerParameterFormData'@
300+ -- This is valid only for either @'ParameterQuery'@ or @'ParameterFormData'@
301 -- and allows you to send a parameter with a name only or an empty value.
301 -- and allows you to send a parameter with a name only or an empty value.
302 -- Default value is @False@.
302 -- Default value is @False@.
303− , _swaggerParameterOtherSchemaAllowEmptyValue :: Maybe Bool
303+ , _parameterOtherSchemaAllowEmptyValue :: Maybe Bool
304
304
305− -- | __Required if type is @'SwaggerParamArray'@__.
305+ -- | __Required if type is @'ParamArray'@__.
306 -- Describes the type of items in the array.
306 -- Describes the type of items in the array.
307− , _swaggerParameterOtherSchemaItems :: Maybe SwaggerItems
307+ , _parameterOtherSchemaItems :: Maybe Items
308
308
309− -- | Determines the format of the array if @'SwaggerParamArray'@ is used.
309+ -- | Determines the format of the array if @'ParamArray'@ is used.
310 -- Default value is csv.
310 -- Default value is csv.
311− , _swaggerParameterOtherSchemaCollectionFormat :: Maybe SwaggerCollectionFormat
311+ , _parameterOtherSchemaCollectionFormat :: Maybe CollectionFormat
312
312
313− , _swaggerParameterOtherSchemaCommon :: SwaggerSchemaCommon
313+ , _parameterOtherSchemaCommon :: SchemaCommon
314 } deriving (Eq, Show, Generic)
314 } deriving (Eq, Show, Generic)
315
315
316−data SwaggerParameterType
316+data ParameterType
317− = SwaggerParamString
317+ = ParamString
318− | SwaggerParamNumber
318+ | ParamNumber
319− | SwaggerParamInteger
319+ | ParamInteger
320− | SwaggerParamBoolean
320+ | ParamBoolean
321− | SwaggerParamArray
321+ | ParamArray
322− | SwaggerParamFile
322+ | ParamFile
323 deriving (Eq, Show)
323 deriving (Eq, Show)
324
324
325−data SwaggerParameterLocation
325+data ParameterLocation
326 = -- | Parameters that are appended to the URL.
326 = -- | Parameters that are appended to the URL.
327 -- For example, in @/items?id=###@, the query parameter is @id@.
327 -- For example, in @/items?id=###@, the query parameter is @id@.
328− SwaggerParameterQuery
328+ ParameterQuery
329 -- | Custom headers that are expected as part of the request.
329 -- | Custom headers that are expected as part of the request.
330− | SwaggerParameterHeader
330+ | ParameterHeader
331 -- | Used together with Path Templating, where the parameter value is actually part of the operation's URL.
331 -- | Used together with Path Templating, where the parameter value is actually part of the operation's URL.
332 -- This does not include the host or base path of the API.
332 -- This does not include the host or base path of the API.
333 -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
333 -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
334− | SwaggerParameterPath
334+ | ParameterPath
335 -- | Used to describe the payload of an HTTP request when either @application/x-www-form-urlencoded@
335 -- | Used to describe the payload of an HTTP request when either @application/x-www-form-urlencoded@
336 -- or @multipart/form-data@ are used as the content type of the request
336 -- or @multipart/form-data@ are used as the content type of the request
337 -- (in Swagger's definition, the @consumes@ property of an operation).
337 -- (in Swagger's definition, the @consumes@ property of an operation).
338− -- This is the only parameter type that can be used to send files, thus supporting the @'SwaggerParamFile'@ type.
338+ -- This is the only parameter type that can be used to send files, thus supporting the @'ParamFile'@ type.
339 -- Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
339 -- Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
340 -- Form parameters have a different format based on the content-type used
340 -- Form parameters have a different format based on the content-type used
341 -- (for further details, consult <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>).
341 -- (for further details, consult <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>).
342− | SwaggerParameterFormData
342+ | ParameterFormData
343 deriving (Eq, Show)
343 deriving (Eq, Show)
344
344
345−type SwaggerFormat = Text
345+type Format = Text
346
346
347-- | Determines the format of the array.
347-- | Determines the format of the array.
348−data SwaggerCollectionFormat
348+data CollectionFormat
349− = SwaggerCollectionCSV -- ^ Comma separated values: @foo,bar@.
349+ = CollectionCSV -- ^ Comma separated values: @foo,bar@.
350− | SwaggerCollectionSSV -- ^ Space separated values: @foo bar@.
350+ | CollectionSSV -- ^ Space separated values: @foo bar@.
351− | SwaggerCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
351+ | CollectionTSV -- ^ Tab separated values: @foo\\tbar@.
352− | SwaggerCollectionPipes -- ^ Pipe separated values: @foo|bar@.
352+ | CollectionPipes -- ^ Pipe separated values: @foo|bar@.
353− | SwaggerCollectionMulti -- ^ Corresponds to multiple parameter instances
353+ | CollectionMulti -- ^ Corresponds to multiple parameter instances
354 -- instead of multiple values for a single instance @foo=bar&foo=baz@.
354 -- instead of multiple values for a single instance @foo=bar&foo=baz@.
355− -- This is valid only for parameters in @'SwaggerParameterQuery'@ or @'SwaggerParameterFormData'@.
355+ -- This is valid only for parameters in @'ParameterQuery'@ or @'ParameterFormData'@.
356 deriving (Eq, Show)
356 deriving (Eq, Show)
357
357
358−data SwaggerItemsType
358+data ItemsType
359− = SwaggerItemsString
359+ = ItemsString
360− | SwaggerItemsNumber
360+ | ItemsNumber
361− | SwaggerItemsInteger
361+ | ItemsInteger
362− | SwaggerItemsBoolean
362+ | ItemsBoolean
363− | SwaggerItemsArray
363+ | ItemsArray
364 deriving (Eq, Show)
364 deriving (Eq, Show)
365
365
366−data SwaggerSchemaType
366+data SchemaType
367− = SwaggerSchemaArray
367+ = SchemaArray
368− | SwaggerSchemaBoolean
368+ | SchemaBoolean
369− | SwaggerSchemaInteger
369+ | SchemaInteger
370− | SwaggerSchemaNumber
370+ | SchemaNumber
371− | SwaggerSchemaNull
371+ | SchemaNull
372− | SwaggerSchemaObject
372+ | SchemaObject
373− | SwaggerSchemaString
373+ | SchemaString
374 deriving (Eq, Show)
374 deriving (Eq, Show)
375
375
376-- | Determines the format of the nested array.
376-- | Determines the format of the nested array.
377−data SwaggerItemsCollectionFormat
377+data ItemsCollectionFormat
378− = SwaggerItemsCollectionCSV -- ^ Comma separated values: @foo,bar@.
378+ = ItemsCollectionCSV -- ^ Comma separated values: @foo,bar@.
379− | SwaggerItemsCollectionSSV -- ^ Space separated values: @foo bar@.
379+ | ItemsCollectionSSV -- ^ Space separated values: @foo bar@.
380− | SwaggerItemsCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
380+ | ItemsCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
381− | SwaggerItemsCollectionPipes -- ^ Pipe separated values: @foo|bar@.
381+ | ItemsCollectionPipes -- ^ Pipe separated values: @foo|bar@.
382 deriving (Eq, Show)
382 deriving (Eq, Show)
383
383
384−type SwaggerParamName = Text
384+type ParamName = Text
385
385
386−data SwaggerSchema = SwaggerSchema
386+data Schema = Schema
387− { _swaggerSchemaType :: SwaggerSchemaType
387+ { _schemaType :: SchemaType
388− , _swaggerSchemaFormat :: Maybe SwaggerFormat
388+ , _schemaFormat :: Maybe Format
389− , _swaggerSchemaTitle :: Maybe Text
389+ , _schemaTitle :: Maybe Text
390− , _swaggerSchemaDescription :: Maybe Text
390+ , _schemaDescription :: Maybe Text
391− , _swaggerSchemaRequired :: [SwaggerParamName]
391+ , _schemaRequired :: [ParamName]
392
392
393− , _swaggerSchemaItems :: Maybe SwaggerSchemaItems
393+ , _schemaItems :: Maybe SchemaItems
394− , _swaggerSchemaAllOf :: Maybe [SwaggerSchema]
394+ , _schemaAllOf :: Maybe [Schema]
395− , _swaggerSchemaProperties :: HashMap Text (SwaggerReferenced SwaggerSchema)
395+ , _schemaProperties :: HashMap Text (Referenced Schema)
396− , _swaggerSchemaAdditionalProperties :: Maybe SwaggerSchema
396+ , _schemaAdditionalProperties :: Maybe Schema
397
397
398− , _swaggerSchemaDiscriminator :: Maybe Text
398+ , _schemaDiscriminator :: Maybe Text
399− , _swaggerSchemaReadOnly :: Maybe Bool
399+ , _schemaReadOnly :: Maybe Bool
400− , _swaggerSchemaXml :: Maybe SwaggerXml
400+ , _schemaXml :: Maybe Xml
401− , _swaggerSchemaExternalDocs :: Maybe SwaggerExternalDocs
401+ , _schemaExternalDocs :: Maybe ExternalDocs
402− , _swaggerSchemaExample :: Maybe Value
402+ , _schemaExample :: Maybe Value
403
403
404− , _swaggerSchemaMaxProperties :: Maybe Integer
404+ , _schemaMaxProperties :: Maybe Integer
405− , _swaggerSchemaMinProperties :: Maybe Integer
405+ , _schemaMinProperties :: Maybe Integer
406
406
407− , _swaggerSchemaCommon :: SwaggerSchemaCommon
407+ , _schemaSchemaCommon :: SchemaCommon
408 } deriving (Eq, Show, Generic)
408 } deriving (Eq, Show, Generic)
409
409
410−data SwaggerSchemaItems
410+data SchemaItems
411− = SwaggerSchemaItemsObject (SwaggerReferenced SwaggerSchema)
411+ = SchemaItemsObject (Referenced Schema)
412− | SwaggerSchemaItemsArray [SwaggerReferenced SwaggerSchema]
412+ | SchemaItemsArray [Referenced Schema]
413 deriving (Eq, Show)
413 deriving (Eq, Show)
414
414
415−data SwaggerSchemaCommon = SwaggerSchemaCommon
415+data SchemaCommon = SchemaCommon
416 { -- | Declares the value of the parameter that the server will use if none is provided,
416 { -- | Declares the value of the parameter that the server will use if none is provided,
417 -- for example a @"count"@ to control the number of results per page might default to @100@
417 -- for example a @"count"@ to control the number of results per page might default to @100@
418 -- if not supplied by the client in the request.
418 -- if not supplied by the client in the request.
419 -- (Note: "default" has no meaning for required parameters.)
419 -- (Note: "default" has no meaning for required parameters.)
420 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
420 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
421− _swaggerSchemaDefault :: Maybe Value
421+ _schemaCommonDefault :: Maybe Value
422−
422+
423− , _swaggerSchemaMaximum :: Maybe Integer
423+ , _schemaCommonMaximum :: Maybe Integer
424− , _swaggerSchemaExclusiveMaximum :: Maybe Bool
424+ , _schemaCommonExclusiveMaximum :: Maybe Bool
425− , _swaggerSchemaMinimum :: Maybe Integer
425+ , _schemaCommonMinimum :: Maybe Integer
426− , _swaggerSchemaExclusiveMinimum :: Maybe Bool
426+ , _schemaCommonExclusiveMinimum :: Maybe Bool
427− , _swaggerSchemaMaxLength :: Maybe Integer
427+ , _schemaCommonMaxLength :: Maybe Integer
428− , _swaggerSchemaMinLength :: Maybe Integer
428+ , _schemaCommonMinLength :: Maybe Integer
429− , _swaggerSchemaPattern :: Maybe Text
429+ , _schemaCommonPattern :: Maybe Text
430− , _swaggerSchemaMaxItems :: Maybe Integer
430+ , _schemaCommonMaxItems :: Maybe Integer
431− , _swaggerSchemaMinItems :: Maybe Integer
431+ , _schemaCommonMinItems :: Maybe Integer
432− , _swaggerSchemaUniqueItems :: Maybe Bool
432+ , _schemaCommonUniqueItems :: Maybe Bool
433− , _swaggerSchemaEnum :: Maybe [Value]
433+ , _schemaCommonEnum :: Maybe [Value]
434− , _swaggerSchemaMultipleOf :: Maybe Integer
434+ , _schemaCommonMultipleOf :: Maybe Integer
435 } deriving (Eq, Show, Generic)
435 } deriving (Eq, Show, Generic)
436
436
437−data SwaggerXml = SwaggerXml
437+data Xml = Xml
438 { -- | Replaces the name of the element/attribute used for the described schema property.
438 { -- | Replaces the name of the element/attribute used for the described schema property.
439− -- When defined within the @'SwaggerItems'@ (items), it will affect the name of the individual XML elements within the list.
439+ -- When defined within the @'Items'@ (items), it will affect the name of the individual XML elements within the list.
440 -- When defined alongside type being array (outside the items),
440 -- When defined alongside type being array (outside the items),
441 -- it will affect the wrapping element and only if wrapped is true.
441 -- it will affect the wrapping element and only if wrapped is true.
442 -- If wrapped is false, it will be ignored.
442 -- If wrapped is false, it will be ignored.
443− _swaggerXmlName :: Maybe Text
443+ _xmlName :: Maybe Text
444
444
445 -- | The URL of the namespace definition.
445 -- | The URL of the namespace definition.
446 -- Value SHOULD be in the form of a URL.
446 -- Value SHOULD be in the form of a URL.
447− , _swaggerXmlNamespace :: Maybe Text
447+ , _xmlNamespace :: Maybe Text
448
448
449 -- | The prefix to be used for the name.
449 -- | The prefix to be used for the name.
450− , _swaggerXmlPrefix :: Maybe Text
450+ , _xmlPrefix :: Maybe Text
451
451
452 -- | Declares whether the property definition translates to an attribute instead of an element.
452 -- | Declares whether the property definition translates to an attribute instead of an element.
453 -- Default value is @False@.
453 -- Default value is @False@.
454− , _swaggerXmlAttribute :: Maybe Bool
454+ , _xmlAttribute :: Maybe Bool
455
455
456 -- | MAY be used only for an array definition.
456 -- | MAY be used only for an array definition.
457 -- Signifies whether the array is wrapped
457 -- Signifies whether the array is wrapped
@@ -459,25 +459,25 @@ data SwaggerXml = SwaggerXml
459 -- or unwrapped (@\<book/\>\<book/\>@).
459 -- or unwrapped (@\<book/\>\<book/\>@).
460 -- Default value is @False@.
460 -- Default value is @False@.
461 -- The definition takes effect only when defined alongside type being array (outside the items).
461 -- The definition takes effect only when defined alongside type being array (outside the items).
462− , _swaggerXmlWrapped :: Maybe Bool
462+ , _xmlWrapped :: Maybe Bool
463 } deriving (Eq, Show, Generic)
463 } deriving (Eq, Show, Generic)
464
464
465−data SwaggerItems = SwaggerItems
465+data Items = Items
466 { -- | The internal type of the array.
466 { -- | The internal type of the array.
467− _swaggerItemsType :: SwaggerItemsType
467+ _itemsType :: ItemsType
468
468
469 -- | The extending format for the previously mentioned type.
469 -- | The extending format for the previously mentioned type.
470− , _swaggerItemsFormat :: Maybe SwaggerFormat
470+ , _itemsFormat :: Maybe Format
471
471
472− -- | __Required if type is @'SwaggerItemsArray'@.__
472+ -- | __Required if type is @'ItemsArray'@.__
473 -- Describes the type of items in the array.
473 -- Describes the type of items in the array.
474− , _swaggerItemsItems :: Maybe SwaggerItems
474+ , _itemsItems :: Maybe Items
475
475
476 -- | Determines the format of the array if type array is used.
476 -- | Determines the format of the array if type array is used.
477− -- Default value is @'SwaggerItemsCollectionCSV'@.
477+ -- Default value is @'ItemsCollectionCSV'@.
478− , _swaggerItemsCollectionFormat :: Maybe SwaggerItemsCollectionFormat
478+ , _itemsCollectionFormat :: Maybe ItemsCollectionFormat
479
479
480− , _swaggerItemsCommon :: SwaggerSchemaCommon
480+ , _itemsCommon :: SchemaCommon
481 } deriving (Eq, Show, Generic)
481 } deriving (Eq, Show, Generic)
482
482
483-- | A container for the expected responses of an operation.
483-- | A container for the expected responses of an operation.
@@ -485,76 +485,76 @@ data SwaggerItems = SwaggerItems
485-- It is not expected from the documentation to necessarily cover all possible HTTP response codes,
485-- It is not expected from the documentation to necessarily cover all possible HTTP response codes,
486-- since they may not be known in advance.
486-- since they may not be known in advance.
487-- However, it is expected from the documentation to cover a successful operation response and any known errors.
487-- However, it is expected from the documentation to cover a successful operation response and any known errors.
488−data SwaggerResponses = SwaggerResponses
488+data Responses = Responses
489 { -- | The documentation of responses other than the ones declared for specific HTTP response codes.
489 { -- | The documentation of responses other than the ones declared for specific HTTP response codes.
490 -- It can be used to cover undeclared responses.
490 -- It can be used to cover undeclared responses.
491− _swaggerResponsesDefault :: Maybe (SwaggerReferenced SwaggerResponse)
491+ _responsesDefault :: Maybe (Referenced Response)
492
492
493 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
493 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
494 -- Describes the expected response for those HTTP status codes.
494 -- Describes the expected response for those HTTP status codes.
495− , _swaggerResponsesResponses :: HashMap HttpStatusCode (SwaggerReferenced SwaggerResponse)
495+ , _responsesResponses :: HashMap HttpStatusCode (Referenced Response)
496 } deriving (Eq, Show, Generic)
496 } deriving (Eq, Show, Generic)
497
497
498type HttpStatusCode = Int
498type HttpStatusCode = Int
499
499
500-- | Describes a single response from an API Operation.
500-- | Describes a single response from an API Operation.
501−data SwaggerResponse = SwaggerResponse
501+data Response = Response
502 { -- | A short description of the response.
502 { -- | A short description of the response.
503 -- GFM syntax can be used for rich text representation.
503 -- GFM syntax can be used for rich text representation.
504− _swaggerResponseDescription :: Text
504+ _responseDescription :: Text
505
505
506 -- | A definition of the response structure.
506 -- | A definition of the response structure.
507 -- It can be a primitive, an array or an object.
507 -- It can be a primitive, an array or an object.
508 -- If this field does not exist, it means no content is returned as part of the response.
508 -- If this field does not exist, it means no content is returned as part of the response.
509 -- As an extension to the Schema Object, its root type value may also be "file".
509 -- As an extension to the Schema Object, its root type value may also be "file".
510 -- This SHOULD be accompanied by a relevant produces mime-type.
510 -- This SHOULD be accompanied by a relevant produces mime-type.
511− , _swaggerResponseSchema :: Maybe (SwaggerReferenced SwaggerSchema)
511+ , _responseSchema :: Maybe (Referenced Schema)
512
512
513 -- | A list of headers that are sent with the response.
513 -- | A list of headers that are sent with the response.
514− , _swaggerResponseHeaders :: HashMap HeaderName SwaggerHeader
514+ , _responseHeaders :: HashMap HeaderName Header
515
515
516 -- | An example of the response message.
516 -- | An example of the response message.
517− , _swaggerResponseExamples :: Maybe SwaggerExample
517+ , _responseExamples :: Maybe Example
518 } deriving (Eq, Show, Generic)
518 } deriving (Eq, Show, Generic)
519
519
520type HeaderName = Text
520type HeaderName = Text
521
521
522−data SwaggerHeader = SwaggerHeader
522+data Header = Header
523 { -- | A short description of the header.
523 { -- | A short description of the header.
524− _swaggerHeaderDescription :: Maybe Text
524+ _headerDescription :: Maybe Text
525
525
526 -- | The type of the object.
526 -- | The type of the object.
527− , _swaggerHeaderType :: SwaggerItemsType
527+ , _headerType :: ItemsType
528
528
529 -- | The extending format for the previously mentioned type. See Data Type Formats for further details.
529 -- | The extending format for the previously mentioned type. See Data Type Formats for further details.
530− , _swaggerHeaderFormat :: Maybe SwaggerFormat
530+ , _headerFormat :: Maybe Format
531
531
532− -- | __Required if type is @'SwaggerItemsArray'@__.
532+ -- | __Required if type is @'ItemsArray'@__.
533 -- Describes the type of items in the array.
533 -- Describes the type of items in the array.
534− , _swaggerHeaderItems :: Maybe SwaggerItems
534+ , _headerItems :: Maybe Items
535
535
536 -- | Determines the format of the array if type array is used.
536 -- | Determines the format of the array if type array is used.
537− -- Default value is @'SwaggerItemsCollectionCSV'@.
537+ -- Default value is @'ItemsCollectionCSV'@.
538− , _swaggerHeaderCollectionFormat :: Maybe SwaggerItemsCollectionFormat
538+ , _headerCollectionFormat :: Maybe ItemsCollectionFormat
539
539
540− , _swaggerHeaderCommon :: SwaggerSchemaCommon
540+ , _headerCommon :: SchemaCommon
541 } deriving (Eq, Show, Generic)
541 } deriving (Eq, Show, Generic)
542
542
543−data SwaggerExample = SwaggerExample { getSwaggerExample :: Map MediaType Value }
543+data Example = Example { getExample :: Map MediaType Value }
544 deriving (Eq, Show)
544 deriving (Eq, Show)
545
545
546-- | The location of the API key.
546-- | The location of the API key.
547−data SwaggerApiKeyLocation
547+data ApiKeyLocation
548− = SwaggerApiKeyQuery
548+ = ApiKeyQuery
549− | SwaggerApiKeyHeader
549+ | ApiKeyHeader
550 deriving (Eq, Show)
550 deriving (Eq, Show)
551
551
552−data SwaggerApiKeyParams = SwaggerApiKeyParams
552+data ApiKeyParams = ApiKeyParams
553 { -- | The name of the header or query parameter to be used.
553 { -- | The name of the header or query parameter to be used.
554− _swaggerApiKeyName :: Text
554+ _apiKeyName :: Text
555
555
556 -- | The location of the API key.
556 -- | The location of the API key.
557− , _swaggerApiKeyIn :: SwaggerApiKeyLocation
557+ , _apiKeyIn :: ApiKeyLocation
558 } deriving (Eq, Show)
558 } deriving (Eq, Show)
559
559
560-- | The authorization URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.
560-- | The authorization URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.
@@ -563,74 +563,74 @@ type AuthorizationURL = Text
563-- | The token URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.
563-- | The token URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.
564type TokenURL = Text
564type TokenURL = Text
565
565
566−data SwaggerOAuth2Flow
566+data OAuth2Flow
567− = SwaggerOAuth2Implicit AuthorizationURL
567+ = OAuth2Implicit AuthorizationURL
568− | SwaggerOAuth2Password TokenURL
568+ | OAuth2Password TokenURL
569− | SwaggerOAuth2Application TokenURL
569+ | OAuth2Application TokenURL
570− | SwaggerOAuth2AccessCode AuthorizationURL TokenURL
570+ | OAuth2AccessCode AuthorizationURL TokenURL
571 deriving (Eq, Show)
571 deriving (Eq, Show)
572
572
573−data SwaggerOAuth2Params = SwaggerOAuth2Params
573+data OAuth2Params = OAuth2Params
574 { -- | The flow used by the OAuth2 security scheme.
574 { -- | The flow used by the OAuth2 security scheme.
575− _swaggerOAuth2Flow :: SwaggerOAuth2Flow
575+ _oauth2Flow :: OAuth2Flow
576
576
577 -- | The available scopes for the OAuth2 security scheme.
577 -- | The available scopes for the OAuth2 security scheme.
578− , _swaggerOAuth2Scopes :: HashMap Text Text
578+ , _oauth2Scopes :: HashMap Text Text
579 } deriving (Eq, Show, Generic)
579 } deriving (Eq, Show, Generic)
580
580
581−data SwaggerSecuritySchemeType
581+data SecuritySchemeType
582− = SwaggerSecuritySchemeBasic
582+ = SecuritySchemeBasic
583− | SwaggerSecuritySchemeApiKey SwaggerApiKeyParams
583+ | SecuritySchemeApiKey ApiKeyParams
584− | SwaggerSecuritySchemeOAuth2 SwaggerOAuth2Params
584+ | SecuritySchemeOAuth2 OAuth2Params
585 deriving (Eq, Show)
585 deriving (Eq, Show)
586
586
587−data SwaggerSecurityScheme = SwaggerSecurityScheme
587+data SecurityScheme = SecurityScheme
588 { -- | The type of the security scheme.
588 { -- | The type of the security scheme.
589− _swaggerSecuritySchemeType :: SwaggerSecuritySchemeType
589+ _securitySchemeType :: SecuritySchemeType
590
590
591 -- | A short description for security scheme.
591 -- | A short description for security scheme.
592− , _swaggerSecuritySchemeDescription :: Maybe Text
592+ , _securitySchemeDescription :: Maybe Text
593 } deriving (Eq, Show, Generic)
593 } deriving (Eq, Show, Generic)
594
594
595-- | Lists the required security schemes to execute this operation.
595-- | Lists the required security schemes to execute this operation.
596-- The object can have multiple security schemes declared in it which are all required
596-- The object can have multiple security schemes declared in it which are all required
597-- (that is, there is a logical AND between the schemes).
597-- (that is, there is a logical AND between the schemes).
598−newtype SwaggerSecurityRequirement = SwaggerSecurityRequirement
598+newtype SecurityRequirement = SecurityRequirement
599− { getSwaggerSecurityRequirement :: HashMap Text [Text]
599+ { getSecurityRequirement :: HashMap Text [Text]
600 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON)
600 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON)
601
601
602−-- | Allows adding meta data to a single tag that is used by @SwaggerOperation@.
602+-- | Allows adding meta data to a single tag that is used by @Operation@.
603−-- It is not mandatory to have a @SwaggerTag@ per tag used there.
603+-- It is not mandatory to have a @Tag@ per tag used there.
604−data SwaggerTag = SwaggerTag
604+data Tag = Tag
605 { -- | The name of the tag.
605 { -- | The name of the tag.
606− _swaggerTagName :: Text
606+ _tagName :: Text
607
607
608 -- | A short description for the tag.
608 -- | A short description for the tag.
609 -- GFM syntax can be used for rich text representation.
609 -- GFM syntax can be used for rich text representation.
610− , _swaggerTagDescription :: Maybe Text
610+ , _tagDescription :: Maybe Text
611
611
612 -- | Additional external documentation for this tag.
612 -- | Additional external documentation for this tag.
613− , _swaggerTagExternalDocs :: Maybe SwaggerExternalDocs
613+ , _tagExternalDocs :: Maybe ExternalDocs
614 } deriving (Eq, Show)
614 } deriving (Eq, Show)
615
615
616-- | Allows referencing an external resource for extended documentation.
616-- | Allows referencing an external resource for extended documentation.
617−data SwaggerExternalDocs = SwaggerExternalDocs
617+data ExternalDocs = ExternalDocs
618 { -- | A short description of the target documentation.
618 { -- | A short description of the target documentation.
619 -- GFM syntax can be used for rich text representation.
619 -- GFM syntax can be used for rich text representation.
620− _swaggerExternalDocsDescription :: Maybe Text
620+ _externalDocsDescription :: Maybe Text
621
621
622 -- | The URL for the target documentation.
622 -- | The URL for the target documentation.
623− , _swaggerExternalDocsUrl :: URL
623+ , _externalDocsUrl :: URL
624 } deriving (Eq, Show, Generic)
624 } deriving (Eq, Show, Generic)
625
625
626-- | A simple object to allow referencing other definitions in the specification.
626-- | A simple object to allow referencing other definitions in the specification.
627-- It can be used to reference parameters and responses that are defined at the top level for reuse.
627-- It can be used to reference parameters and responses that are defined at the top level for reuse.
628−newtype SwaggerReference = SwaggerReference { getSwaggerReference :: Text }
628+newtype Reference = Reference { getReference :: Text }
629 deriving (Eq, Show)
629 deriving (Eq, Show)
630
630
631−data SwaggerReferenced a
631+data Referenced a
632− = SwaggerRef SwaggerReference
632+ = Ref Reference
633− | SwaggerInline a
633+ | Inline a
634 deriving (Eq, Show)
634 deriving (Eq, Show)
635
635
636newtype URL = URL { getUrl :: Text } deriving (Eq, Show, ToJSON, FromJSON)
636newtype URL = URL { getUrl :: Text } deriving (Eq, Show, ToJSON, FromJSON)
@@ -643,47 +643,47 @@ instance Monoid Swagger where
643 mempty = genericMempty
643 mempty = genericMempty
644 mappend = genericMappend
644 mappend = genericMappend
645
645
646−instance Monoid SwaggerInfo where
646+instance Monoid Info where
647 mempty = genericMempty
647 mempty = genericMempty
648 mappend = genericMappend
648 mappend = genericMappend
649
649
650−instance Monoid SwaggerPaths where
650+instance Monoid Paths where
651 mempty = genericMempty
651 mempty = genericMempty
652 mappend = genericMappend
652 mappend = genericMappend
653
653
654−instance Monoid SwaggerPathItem where
654+instance Monoid PathItem where
655 mempty = genericMempty
655 mempty = genericMempty
656 mappend = genericMappend
656 mappend = genericMappend
657
657
658−instance Monoid SwaggerSchema where
658+instance Monoid Schema where
659 mempty = genericMempty
659 mempty = genericMempty
660 mappend = genericMappend
660 mappend = genericMappend
661
661
662−instance Monoid SwaggerSchemaCommon where
662+instance Monoid SchemaCommon where
663 mempty = genericMempty
663 mempty = genericMempty
664 mappend = genericMappend
664 mappend = genericMappend
665
665
666−instance Monoid SwaggerParameter where
666+instance Monoid Parameter where
667 mempty = genericMempty
667 mempty = genericMempty
668 mappend = genericMappend
668 mappend = genericMappend
669
669
670−instance Monoid SwaggerParameterOtherSchema where
670+instance Monoid ParameterOtherSchema where
671 mempty = genericMempty
671 mempty = genericMempty
672 mappend = genericMappend
672 mappend = genericMappend
673
673
674−instance Monoid SwaggerResponses where
674+instance Monoid Responses where
675 mempty = genericMempty
675 mempty = genericMempty
676 mappend = genericMappend
676 mappend = genericMappend
677
677
678−instance Monoid SwaggerResponse where
678+instance Monoid Response where
679 mempty = genericMempty
679 mempty = genericMempty
680 mappend = genericMappend
680 mappend = genericMappend
681
681
682−instance Monoid SwaggerExternalDocs where
682+instance Monoid ExternalDocs where
683 mempty = genericMempty
683 mempty = genericMempty
684 mappend = genericMappend
684 mappend = genericMappend
685
685
686−instance Monoid SwaggerOperation where
686+instance Monoid Operation where
687 mempty = genericMempty
687 mempty = genericMempty
688 mappend = genericMappend
688 mappend = genericMappend
689
689
@@ -691,217 +691,217 @@ instance Monoid SwaggerOperation where
691-- SwaggerMonoid helper instances
691-- SwaggerMonoid helper instances
692-- =======================================================================
692-- =======================================================================
693
693
694−instance SwaggerMonoid SwaggerInfo
694+instance SwaggerMonoid Info
695−instance SwaggerMonoid SwaggerPaths
695+instance SwaggerMonoid Paths
696−instance SwaggerMonoid SwaggerPathItem
696+instance SwaggerMonoid PathItem
697−instance SwaggerMonoid SwaggerSchema
697+instance SwaggerMonoid Schema
698−instance SwaggerMonoid SwaggerSchemaCommon
698+instance SwaggerMonoid SchemaCommon
699−instance SwaggerMonoid SwaggerParameter
699+instance SwaggerMonoid Parameter
700−instance SwaggerMonoid SwaggerParameterOtherSchema
700+instance SwaggerMonoid ParameterOtherSchema
701−instance SwaggerMonoid SwaggerResponses
701+instance SwaggerMonoid Responses
702−instance SwaggerMonoid SwaggerResponse
702+instance SwaggerMonoid Response
703−instance SwaggerMonoid SwaggerExternalDocs
703+instance SwaggerMonoid ExternalDocs
704−instance SwaggerMonoid SwaggerOperation
704+instance SwaggerMonoid Operation
705−
705+
706−instance SwaggerMonoid SwaggerMimeList
706+instance SwaggerMonoid MimeList
707deriving instance SwaggerMonoid URL
707deriving instance SwaggerMonoid URL
708
708
709−instance SwaggerMonoid SwaggerSchemaType where
709+instance SwaggerMonoid SchemaType where
710− swaggerMempty = SwaggerSchemaNull
710+ swaggerMempty = SchemaNull
711 swaggerMappend _ y = y
711 swaggerMappend _ y = y
712
712
713−instance SwaggerMonoid SwaggerParameterType where
713+instance SwaggerMonoid ParameterType where
714− swaggerMempty = SwaggerParamString
714+ swaggerMempty = ParamString
715 swaggerMappend _ y = y
715 swaggerMappend _ y = y
716
716
717−instance SwaggerMonoid SwaggerParameterLocation where
717+instance SwaggerMonoid ParameterLocation where
718− swaggerMempty = SwaggerParameterQuery
718+ swaggerMempty = ParameterQuery
719 swaggerMappend _ y = y
719 swaggerMappend _ y = y
720
720
721−instance SwaggerMonoid (HashMap Text SwaggerSchema) where
721+instance SwaggerMonoid (HashMap Text Schema) where
722 swaggerMempty = HashMap.empty
722 swaggerMempty = HashMap.empty
723 swaggerMappend = HashMap.unionWith mappend
723 swaggerMappend = HashMap.unionWith mappend
724
724
725−instance SwaggerMonoid (HashMap Text (SwaggerReferenced SwaggerSchema)) where
725+instance SwaggerMonoid (HashMap Text (Referenced Schema)) where
726 swaggerMempty = HashMap.empty
726 swaggerMempty = HashMap.empty
727 swaggerMappend = HashMap.unionWith swaggerMappend
727 swaggerMappend = HashMap.unionWith swaggerMappend
728
728
729−instance Monoid a => SwaggerMonoid (SwaggerReferenced a) where
729+instance Monoid a => SwaggerMonoid (Referenced a) where
730− swaggerMempty = SwaggerInline mempty
730+ swaggerMempty = Inline mempty
731− swaggerMappend (SwaggerInline x) (SwaggerInline y) = SwaggerInline (x <> y)
731+ swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
732 swaggerMappend _ y = y
732 swaggerMappend _ y = y
733
733
734−instance SwaggerMonoid (HashMap Text SwaggerParameter) where
734+instance SwaggerMonoid (HashMap Text Parameter) where
735 swaggerMempty = HashMap.empty
735 swaggerMempty = HashMap.empty
736 swaggerMappend = HashMap.unionWith mappend
736 swaggerMappend = HashMap.unionWith mappend
737
737
738−instance SwaggerMonoid (HashMap Text SwaggerResponse) where
738+instance SwaggerMonoid (HashMap Text Response) where
739 swaggerMempty = HashMap.empty
739 swaggerMempty = HashMap.empty
740 swaggerMappend = flip HashMap.union
740 swaggerMappend = flip HashMap.union
741
741
742−instance SwaggerMonoid (HashMap Text SwaggerSecurityScheme) where
742+instance SwaggerMonoid (HashMap Text SecurityScheme) where
743 swaggerMempty = HashMap.empty
743 swaggerMempty = HashMap.empty
744 swaggerMappend = flip HashMap.union
744 swaggerMappend = flip HashMap.union
745
745
746−instance SwaggerMonoid (HashMap FilePath SwaggerPathItem) where
746+instance SwaggerMonoid (HashMap FilePath PathItem) where
747 swaggerMempty = HashMap.empty
747 swaggerMempty = HashMap.empty
748 swaggerMappend = HashMap.unionWith mappend
748 swaggerMappend = HashMap.unionWith mappend
749
749
750−instance SwaggerMonoid (HashMap HeaderName SwaggerHeader) where
750+instance SwaggerMonoid (HashMap HeaderName Header) where
751 swaggerMempty = HashMap.empty
751 swaggerMempty = HashMap.empty
752 swaggerMappend = flip HashMap.union
752 swaggerMappend = flip HashMap.union
753
753
754−instance SwaggerMonoid (HashMap HttpStatusCode (SwaggerReferenced SwaggerResponse)) where
754+instance SwaggerMonoid (HashMap HttpStatusCode (Referenced Response)) where
755 swaggerMempty = HashMap.empty
755 swaggerMempty = HashMap.empty
756 swaggerMappend = flip HashMap.union
756 swaggerMappend = flip HashMap.union
757
757
758−instance SwaggerMonoid SwaggerParameterSchema where
758+instance SwaggerMonoid ParameterSchema where
759− swaggerMempty = SwaggerParameterOther swaggerMempty
759+ swaggerMempty = ParameterOther swaggerMempty
760− swaggerMappend (SwaggerParameterBody x) (SwaggerParameterBody y) = SwaggerParameterBody (swaggerMappend x y)
760+ swaggerMappend (ParameterBody x) (ParameterBody y) = ParameterBody (swaggerMappend x y)
761− swaggerMappend (SwaggerParameterOther x) (SwaggerParameterOther y) = SwaggerParameterOther (swaggerMappend x y)
761+ swaggerMappend (ParameterOther x) (ParameterOther y) = ParameterOther (swaggerMappend x y)
762 swaggerMappend _ y = y
762 swaggerMappend _ y = y
763
763
764-- =======================================================================
764-- =======================================================================
765-- TH derived ToJSON and FromJSON instances
765-- TH derived ToJSON and FromJSON instances
766-- =======================================================================
766-- =======================================================================
767
767
768−deriveJSON (jsonPrefix "SwaggerParameter") ''SwaggerParameterLocation
768+deriveJSON (jsonPrefix "Parameter") ''ParameterLocation
769−deriveJSON (jsonPrefix "SwaggerParam") ''SwaggerParameterType
769+deriveJSON (jsonPrefix "Param") ''ParameterType
770−deriveJSON' ''SwaggerInfo
770+deriveJSON' ''Info
771−deriveJSON' ''SwaggerContact
771+deriveJSON' ''Contact
772−deriveJSON' ''SwaggerLicense
772+deriveJSON' ''License
773−deriveJSON (jsonPrefix "SwaggerSchema") ''SwaggerSchemaType
773+deriveJSON (jsonPrefix "Schema") ''SchemaType
774−deriveJSON (jsonPrefix "SwaggerItems") ''SwaggerItemsType
774+deriveJSON (jsonPrefix "Items") ''ItemsType
775−deriveJSON (jsonPrefix "SwaggerItemsCollection") ''SwaggerItemsCollectionFormat
775+deriveJSON (jsonPrefix "ItemsCollection") ''ItemsCollectionFormat
776−deriveJSON (jsonPrefix "SwaggerCollection") ''SwaggerCollectionFormat
776+deriveJSON (jsonPrefix "Collection") ''CollectionFormat
777−deriveJSON (jsonPrefix "SwaggerApiKey") ''SwaggerApiKeyLocation
777+deriveJSON (jsonPrefix "ApiKey") ''ApiKeyLocation
778−deriveJSON (jsonPrefix "swaggerApiKey") ''SwaggerApiKeyParams
778+deriveJSON (jsonPrefix "apiKey") ''ApiKeyParams
779−deriveJSON (jsonPrefix "swaggerSchema") ''SwaggerSchemaCommon
779+deriveJSON' ''SchemaCommon
780−deriveJSONDefault ''SwaggerScheme
780+deriveJSONDefault ''Scheme
781−deriveJSON' ''SwaggerTag
781+deriveJSON' ''Tag
782−deriveJSON' ''SwaggerExternalDocs
782+deriveJSON' ''ExternalDocs
783−
783+
784−deriveToJSON' ''SwaggerOperation
784+deriveToJSON' ''Operation
785−deriveToJSON' ''SwaggerResponse
785+deriveToJSON' ''Response
786−deriveToJSON' ''SwaggerPathItem
786+deriveToJSON' ''PathItem
787−deriveToJSON' ''SwaggerXml
787+deriveToJSON' ''Xml
788
788
789-- =======================================================================
789-- =======================================================================
790-- Manual ToJSON instances
790-- Manual ToJSON instances
791-- =======================================================================
791-- =======================================================================
792
792
793−instance ToJSON SwaggerOAuth2Flow where
793+instance ToJSON OAuth2Flow where
794− toJSON (SwaggerOAuth2Implicit authUrl) = object
794+ toJSON (OAuth2Implicit authUrl) = object
795 [ "flow" .= ("implicit" :: Text)
795 [ "flow" .= ("implicit" :: Text)
796 , "authorizationUrl" .= authUrl ]
796 , "authorizationUrl" .= authUrl ]
797− toJSON (SwaggerOAuth2Password tokenUrl) = object
797+ toJSON (OAuth2Password tokenUrl) = object
798 [ "flow" .= ("password" :: Text)
798 [ "flow" .= ("password" :: Text)
799 , "tokenUrl" .= tokenUrl ]
799 , "tokenUrl" .= tokenUrl ]
800− toJSON (SwaggerOAuth2Application tokenUrl) = object
800+ toJSON (OAuth2Application tokenUrl) = object
801 [ "flow" .= ("application" :: Text)
801 [ "flow" .= ("application" :: Text)
802 , "tokenUrl" .= tokenUrl ]
802 , "tokenUrl" .= tokenUrl ]
803− toJSON (SwaggerOAuth2AccessCode authUrl tokenUrl) = object
803+ toJSON (OAuth2AccessCode authUrl tokenUrl) = object
804 [ "flow" .= ("accessCode" :: Text)
804 [ "flow" .= ("accessCode" :: Text)
805 , "authorizationUrl" .= authUrl
805 , "authorizationUrl" .= authUrl
806 , "tokenUrl" .= tokenUrl ]
806 , "tokenUrl" .= tokenUrl ]
807
807
808−instance ToJSON SwaggerOAuth2Params where
808+instance ToJSON OAuth2Params where
809− toJSON = genericToJSONWithSub "flow" (jsonPrefix "swaggerOAuth2")
809+ toJSON = genericToJSONWithSub "flow" (jsonPrefix "oauth2")
810
810
811−instance ToJSON SwaggerSecuritySchemeType where
811+instance ToJSON SecuritySchemeType where
812− toJSON SwaggerSecuritySchemeBasic
812+ toJSON SecuritySchemeBasic
813 = object [ "type" .= ("basic" :: Text) ]
813 = object [ "type" .= ("basic" :: Text) ]
814− toJSON (SwaggerSecuritySchemeApiKey params)
814+ toJSON (SecuritySchemeApiKey params)
815 = toJSON params
815 = toJSON params
816 <+> object [ "type" .= ("apiKey" :: Text) ]
816 <+> object [ "type" .= ("apiKey" :: Text) ]
817− toJSON (SwaggerSecuritySchemeOAuth2 params)
817+ toJSON (SecuritySchemeOAuth2 params)
818 = toJSON params
818 = toJSON params
819 <+> object [ "type" .= ("oauth2" :: Text) ]
819 <+> object [ "type" .= ("oauth2" :: Text) ]
820
820
821instance ToJSON Swagger where
821instance ToJSON Swagger where
822− toJSON = addVersion . genericToJSON (jsonPrefix "swagger")
822+ toJSON = addVersion . genericToJSON (jsonPrefix "")
823 where
823 where
824 addVersion (Object o) = Object (HashMap.insert "swagger" "2.0" o)
824 addVersion (Object o) = Object (HashMap.insert "swagger" "2.0" o)
825 addVersion _ = error "impossible"
825 addVersion _ = error "impossible"
826
826
827−instance ToJSON SwaggerSecurityScheme where
827+instance ToJSON SecurityScheme where
828− toJSON = genericToJSONWithSub "type" (jsonPrefix "swaggerSecurityScheme")
828+ toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
829
829
830−instance ToJSON SwaggerSchema where
830+instance ToJSON Schema where
831− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerSchema")
831+ toJSON = genericToJSONWithSub "schemaCommon" (jsonPrefix "schema")
832
832
833−instance ToJSON SwaggerHeader where
833+instance ToJSON Header where
834− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerHeader")
834+ toJSON = genericToJSONWithSub "common" (jsonPrefix "header")
835
835
836−instance ToJSON SwaggerItems where
836+instance ToJSON Items where
837− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerItems")
837+ toJSON = genericToJSONWithSub "common" (jsonPrefix "items")
838
838
839−instance ToJSON SwaggerHost where
839+instance ToJSON Host where
840− toJSON (SwaggerHost host mport) = toJSON $
840+ toJSON (Host host mport) = toJSON $
841 case mport of
841 case mport of
842 Nothing -> host
842 Nothing -> host
843 Just port -> host ++ ":" ++ show port
843 Just port -> host ++ ":" ++ show port
844
844
845−instance ToJSON SwaggerPaths where
845+instance ToJSON Paths where
846− toJSON (SwaggerPaths m) = toJSON m
846+ toJSON (Paths m) = toJSON m
847
847
848−instance ToJSON SwaggerMimeList where
848+instance ToJSON MimeList where
849− toJSON (SwaggerMimeList xs) = toJSON (map show xs)
849+ toJSON (MimeList xs) = toJSON (map show xs)
850
850
851−instance ToJSON SwaggerParameter where
851+instance ToJSON Parameter where
852− toJSON = genericToJSONWithSub "schema" (jsonPrefix "swaggerParameter")
852+ toJSON = genericToJSONWithSub "schema" (jsonPrefix "parameter")
853
853
854−instance ToJSON SwaggerParameterSchema where
854+instance ToJSON ParameterSchema where
855− toJSON (SwaggerParameterBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
855+ toJSON (ParameterBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
856− toJSON (SwaggerParameterOther s) = toJSON s
856+ toJSON (ParameterOther s) = toJSON s
857
857
858−instance ToJSON SwaggerParameterOtherSchema where
858+instance ToJSON ParameterOtherSchema where
859− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerParameterOtherSchema")
859+ toJSON = genericToJSONWithSub "common" (jsonPrefix "parameterOtherSchema")
860
860
861−instance ToJSON SwaggerSchemaItems where
861+instance ToJSON SchemaItems where
862− toJSON (SwaggerSchemaItemsObject x) = toJSON x
862+ toJSON (SchemaItemsObject x) = toJSON x
863− toJSON (SwaggerSchemaItemsArray xs) = toJSON xs
863+ toJSON (SchemaItemsArray xs) = toJSON xs
864
864
865−instance ToJSON SwaggerResponses where
865+instance ToJSON Responses where
866− toJSON (SwaggerResponses def rs) = toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
866+ toJSON (Responses def rs) = toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
867
867
868−instance ToJSON SwaggerExample where
868+instance ToJSON Example where
869− toJSON = toJSON . Map.mapKeys show . getSwaggerExample
869+ toJSON = toJSON . Map.mapKeys show . getExample
870
870
871−instance ToJSON SwaggerReference where
871+instance ToJSON Reference where
872− toJSON (SwaggerReference ref) = object [ "$ref" .= ref ]
872+ toJSON (Reference ref) = object [ "$ref" .= ref ]
873
873
874−instance ToJSON a => ToJSON (SwaggerReferenced a) where
874+instance ToJSON a => ToJSON (Referenced a) where
875− toJSON (SwaggerRef ref) = toJSON ref
875+ toJSON (Ref ref) = toJSON ref
876− toJSON (SwaggerInline x) = toJSON x
876+ toJSON (Inline x) = toJSON x
877
877
878-- =======================================================================
878-- =======================================================================
879-- Manual FromJSON instances
879-- Manual FromJSON instances
880-- =======================================================================
880-- =======================================================================
881
881
882−instance FromJSON SwaggerOAuth2Flow where
882+instance FromJSON OAuth2Flow where
883 parseJSON (Object o) = do
883 parseJSON (Object o) = do
884 (flow :: Text) <- o .: "flow"
884 (flow :: Text) <- o .: "flow"
885 case flow of
885 case flow of
886− "implicit" -> SwaggerOAuth2Implicit <$> o .: "authorizationUrl"
886+ "implicit" -> OAuth2Implicit <$> o .: "authorizationUrl"
887− "password" -> SwaggerOAuth2Password <$> o .: "tokenUrl"
887+ "password" -> OAuth2Password <$> o .: "tokenUrl"
888− "application" -> SwaggerOAuth2Application <$> o .: "tokenUrl"
888+ "application" -> OAuth2Application <$> o .: "tokenUrl"
889− "accessCode" -> SwaggerOAuth2AccessCode
889+ "accessCode" -> OAuth2AccessCode
890 <$> o .: "authorizationUrl"
890 <$> o .: "authorizationUrl"
891 <*> o .: "tokenUrl"
891 <*> o .: "tokenUrl"
892 _ -> empty
892 _ -> empty
893 parseJSON _ = empty
893 parseJSON _ = empty
894
894
895−instance FromJSON SwaggerOAuth2Params where
895+instance FromJSON OAuth2Params where
896− parseJSON = genericParseJSONWithSub "flow" (jsonPrefix "swaggerOAuth2")
896+ parseJSON = genericParseJSONWithSub "flow" (jsonPrefix "oauth2")
897
897
898−instance FromJSON SwaggerSecuritySchemeType where
898+instance FromJSON SecuritySchemeType where
899 parseJSON json@(Object o) = do
899 parseJSON json@(Object o) = do
900 (t :: Text) <- o .: "type"
900 (t :: Text) <- o .: "type"
901 case t of
901 case t of
902− "basic" -> pure SwaggerSecuritySchemeBasic
902+ "basic" -> pure SecuritySchemeBasic
903− "apiKey" -> SwaggerSecuritySchemeApiKey <$> parseJSON json
903+ "apiKey" -> SecuritySchemeApiKey <$> parseJSON json
904− "oauth2" -> SwaggerSecuritySchemeOAuth2 <$> parseJSON json
904+ "oauth2" -> SecuritySchemeOAuth2 <$> parseJSON json
905 _ -> empty
905 _ -> empty
906 parseJSON _ = empty
906 parseJSON _ = empty
907
907
@@ -909,101 +909,101 @@ instance FromJSON Swagger where
909 parseJSON json@(Object o) = do
909 parseJSON json@(Object o) = do
910 (version :: Text) <- o .: "swagger"
910 (version :: Text) <- o .: "swagger"
911 when (version /= "2.0") empty
911 when (version /= "2.0") empty
912− (genericParseJSON (jsonPrefix "swagger")
912+ (genericParseJSON (jsonPrefix "")
913− `withDefaults` [ "consumes" .= (mempty :: SwaggerMimeList)
913+ `withDefaults` [ "consumes" .= (mempty :: MimeList)
914− , "produces" .= (mempty :: SwaggerMimeList)
914+ , "produces" .= (mempty :: MimeList)
915− , "security" .= ([] :: [SwaggerSecurityRequirement])
915+ , "security" .= ([] :: [SecurityRequirement])
916− , "tags" .= ([] :: [SwaggerTag])
916+ , "tags" .= ([] :: [Tag])
917− , "definitions" .= (mempty :: HashMap Text SwaggerSchema)
917+ , "definitions" .= (mempty :: HashMap Text Schema)
918− , "parameters" .= (mempty :: HashMap Text SwaggerParameter)
918+ , "parameters" .= (mempty :: HashMap Text Parameter)
919− , "responses" .= (mempty :: HashMap Text SwaggerResponse)
919+ , "responses" .= (mempty :: HashMap Text Response)
920− , "securityDefinitions" .= (mempty :: HashMap Text SwaggerSecurityScheme)
920+ , "securityDefinitions" .= (mempty :: HashMap Text SecurityScheme)
921 ] ) json
921 ] ) json
922 parseJSON _ = empty
922 parseJSON _ = empty
923
923
924−instance FromJSON SwaggerSecurityScheme where
924+instance FromJSON SecurityScheme where
925− parseJSON = genericParseJSONWithSub "type" (jsonPrefix "swaggerSecurityScheme")
925+ parseJSON = genericParseJSONWithSub "type" (jsonPrefix "securityScheme")
926
926
927−instance FromJSON SwaggerSchema where
927+instance FromJSON Schema where
928− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerSchema")
928+ parseJSON = genericParseJSONWithSub "schemaCommon" (jsonPrefix "schema")
929− `withDefaults` [ "properties" .= (mempty :: HashMap Text SwaggerSchema)
929+ `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
930− , "required" .= ([] :: [SwaggerParamName]) ]
930+ , "required" .= ([] :: [ParamName]) ]
931
931
932−instance FromJSON SwaggerHeader where
932+instance FromJSON Header where
933− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerHeader")
933+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "header")
934
934
935−instance FromJSON SwaggerItems where
935+instance FromJSON Items where
936− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerItems")
936+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "items")
937
937
938−instance FromJSON SwaggerHost where
938+instance FromJSON Host where
939 parseJSON (String s) =
939 parseJSON (String s) =
940 case fromInteger <$> readMaybe portStr of
940 case fromInteger <$> readMaybe portStr of
941 Nothing | not (null portStr) -> fail $ "Invalid port `" ++ portStr ++ "'"
941 Nothing | not (null portStr) -> fail $ "Invalid port `" ++ portStr ++ "'"
942− mport -> pure $ SwaggerHost host mport
942+ mport -> pure $ Host host mport
943 where
943 where
944 (hostText, portText) = Text.breakOn ":" s
944 (hostText, portText) = Text.breakOn ":" s
945 [host, portStr] = map Text.unpack [hostText, portText]
945 [host, portStr] = map Text.unpack [hostText, portText]
946 parseJSON _ = empty
946 parseJSON _ = empty
947
947
948−instance FromJSON SwaggerPaths where
948+instance FromJSON Paths where
949− parseJSON json = SwaggerPaths <$> parseJSON json
949+ parseJSON json = Paths <$> parseJSON json
950
950
951−instance FromJSON SwaggerMimeList where
951+instance FromJSON MimeList where
952− parseJSON json = (SwaggerMimeList . map fromString) <$> parseJSON json
952+ parseJSON json = (MimeList . map fromString) <$> parseJSON json
953
953
954−instance FromJSON SwaggerParameter where
954+instance FromJSON Parameter where
955− parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "swaggerParameter")
955+ parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "parameter")
956
956
957−instance FromJSON SwaggerParameterSchema where
957+instance FromJSON ParameterSchema where
958 parseJSON json@(Object o) = do
958 parseJSON json@(Object o) = do
959 (i :: Text) <- o .: "in"
959 (i :: Text) <- o .: "in"
960 case i of
960 case i of
961 "body" -> do
961 "body" -> do
962 schema <- o .: "schema"
962 schema <- o .: "schema"
963− SwaggerParameterBody <$> parseJSON schema
963+ ParameterBody <$> parseJSON schema
964− _ -> SwaggerParameterOther <$> parseJSON json
964+ _ -> ParameterOther <$> parseJSON json
965 parseJSON _ = empty
965 parseJSON _ = empty
966
966
967−instance FromJSON SwaggerParameterOtherSchema where
967+instance FromJSON ParameterOtherSchema where
968− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerParameterOtherSchema")
968+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "parameterOtherSchema")
969
969
970−instance FromJSON SwaggerSchemaItems where
970+instance FromJSON SchemaItems where
971− parseJSON json@(Object _) = SwaggerSchemaItemsObject <$> parseJSON json
971+ parseJSON json@(Object _) = SchemaItemsObject <$> parseJSON json
972− parseJSON json@(Array _) = SwaggerSchemaItemsArray <$> parseJSON json
972+ parseJSON json@(Array _) = SchemaItemsArray <$> parseJSON json
973 parseJSON _ = empty
973 parseJSON _ = empty
974
974
975−instance FromJSON SwaggerResponses where
975+instance FromJSON Responses where
976− parseJSON (Object o) = SwaggerResponses
976+ parseJSON (Object o) = Responses
977 <$> o .:? "default"
977 <$> o .:? "default"
978 <*> (parseJSON (Object (HashMap.delete "default" o)) >>= hashMapReadKeys)
978 <*> (parseJSON (Object (HashMap.delete "default" o)) >>= hashMapReadKeys)
979 parseJSON _ = empty
979 parseJSON _ = empty
980
980
981−instance FromJSON SwaggerExample where
981+instance FromJSON Example where
982 parseJSON json = do
982 parseJSON json = do
983 m <- parseJSON json
983 m <- parseJSON json
984− pure $ SwaggerExample (Map.mapKeys fromString m)
984+ pure $ Example (Map.mapKeys fromString m)
985
985
986−instance FromJSON SwaggerResponse where
986+instance FromJSON Response where
987− parseJSON = genericParseJSON (jsonPrefix "swaggerResponse")
987+ parseJSON = genericParseJSON (jsonPrefix "response")
988− `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName SwaggerHeader) ]
988+ `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName Header) ]
989
989
990−instance FromJSON SwaggerOperation where
990+instance FromJSON Operation where
991− parseJSON = genericParseJSON (jsonPrefix "swaggerOperation")
991+ parseJSON = genericParseJSON (jsonPrefix "operation")
992− `withDefaults` [ "security" .= ([] :: [SwaggerSecurityRequirement]) ]
992+ `withDefaults` [ "security" .= ([] :: [SecurityRequirement]) ]
993
993
994−instance FromJSON SwaggerPathItem where
994+instance FromJSON PathItem where
995− parseJSON = genericParseJSON (jsonPrefix "swaggerPathItem")
995+ parseJSON = genericParseJSON (jsonPrefix "pathItem")
996− `withDefaults` [ "parameters" .= ([] :: [SwaggerParameter]) ]
996+ `withDefaults` [ "parameters" .= ([] :: [Parameter]) ]
997
997
998−instance FromJSON SwaggerReference where
998+instance FromJSON Reference where
999− parseJSON (Object o) = SwaggerReference <$> o .: "$ref"
999+ parseJSON (Object o) = Reference <$> o .: "$ref"
1000 parseJSON _ = empty
1000 parseJSON _ = empty
1001
1001
1002−instance FromJSON a => FromJSON (SwaggerReferenced a) where
1002+instance FromJSON a => FromJSON (Referenced a) where
1003 parseJSON json
1003 parseJSON json
1004− = SwaggerRef <$> parseJSON json
1004+ = Ref <$> parseJSON json
1005− <|> SwaggerInline <$> parseJSON json
1005+ <|> Inline <$> parseJSON json
1006
1006
1007−instance FromJSON SwaggerXml where
1007+instance FromJSON Xml where
1008− parseJSON = genericParseJSON (jsonPrefix "swaggerXml")
1008+ parseJSON = genericParseJSON (jsonPrefix "xml")
1009
1009
src/Data/Swagger/Internal/Utils.hs+3−3
@@ -58,17 +58,17 @@ genericToJSONWithSub sub opts x =
58 Object o ->
58 Object o ->
59 let so = HashMap.lookupDefault (error "impossible") sub o
59 let so = HashMap.lookupDefault (error "impossible") sub o
60 in Object (HashMap.delete sub o) <+> so
60 in Object (HashMap.delete sub o) <+> so
61− _ -> error "impossible"
61+ _ -> error "genericToJSONWithSub: subjson is not an object"
62
62
63genericParseJSONWithSub :: (Generic a, GFromJSON (Rep a)) => Text -> Options -> Value -> Parser a
63genericParseJSONWithSub :: (Generic a, GFromJSON (Rep a)) => Text -> Options -> Value -> Parser a
64genericParseJSONWithSub sub opts (Object o) = genericParseJSON opts json
64genericParseJSONWithSub sub opts (Object o) = genericParseJSON opts json
65 where
65 where
66 json = Object (HashMap.insert sub (Object o) o)
66 json = Object (HashMap.insert sub (Object o) o)
67−genericParseJSONWithSub _ _ _ = error "impossible"
67+genericParseJSONWithSub _ _ _ = error "genericParseJSONWithSub: given json is not an object"
68
68
69(<+>) :: Value -> Value -> Value
69(<+>) :: Value -> Value -> Value
70Object x <+> Object y = Object (x <> y)
70Object x <+> Object y = Object (x <> y)
71−_ <+> _ = error "impossible"
71+_ <+> _ = error "<+>: merging non-objects"
72
72
73withDefaults :: (Value -> Parser a) -> [Pair] -> Value -> Parser a
73withDefaults :: (Value -> Parser a) -> [Pair] -> Value -> Parser a
74withDefaults parser defs json@(Object _) = parser (json <+> object defs)
74withDefaults parser defs json@(Object _) = parser (json <+> object defs)
src/Data/Swagger/Lens.hs+66−66
@@ -15,30 +15,30 @@ import Data.Text (Text)
15-- =======================================================================
15-- =======================================================================
16
16
17makeLenses ''Swagger
17makeLenses ''Swagger
18−makeLenses ''SwaggerHost
18+makeLenses ''Host
19−makeLenses ''SwaggerInfo
19+makeLenses ''Info
20−makeLenses ''SwaggerContact
20+makeLenses ''Contact
21−makeLenses ''SwaggerLicense
21+makeLenses ''License
22−makeLenses ''SwaggerPaths
22+makeLenses ''Paths
23−makeLenses ''SwaggerPathItem
23+makeLenses ''PathItem
24−makeLenses ''SwaggerTag
24+makeLenses ''Tag
25−makeLenses ''SwaggerOperation
25+makeLenses ''Operation
26−makeLenses ''SwaggerParameter
26+makeLenses ''Parameter
27−makePrisms ''SwaggerParameterSchema
27+makePrisms ''ParameterSchema
28−makeLenses ''SwaggerParameterOtherSchema
28+makeLenses ''ParameterOtherSchema
29−makeLenses ''SwaggerItems
29+makeLenses ''Items
30−makeLenses ''SwaggerHeader
30+makeLenses ''Header
31−makeLenses ''SwaggerSchema
31+makeLenses ''Schema
32−makePrisms ''SwaggerSchemaItems
32+makePrisms ''SchemaItems
33−makeLenses ''SwaggerSchemaCommon
33+makeLenses ''SchemaCommon
34−makeLenses ''SwaggerXml
34+makeLenses ''Xml
35−makeLenses ''SwaggerResponses
35+makeLenses ''Responses
36−makeLenses ''SwaggerResponse
36+makeLenses ''Response
37−makeLenses ''SwaggerSecurityScheme
37+makeLenses ''SecurityScheme
38−makePrisms ''SwaggerSecuritySchemeType
38+makePrisms ''SecuritySchemeType
39−makeLenses ''SwaggerApiKeyParams
39+makeLenses ''ApiKeyParams
40−makeLenses ''SwaggerOAuth2Params
40+makeLenses ''OAuth2Params
41−makeLenses ''SwaggerExternalDocs
41+makeLenses ''ExternalDocs
42
42
43-- =======================================================================
43-- =======================================================================
44-- Helper classy lenses
44-- Helper classy lenses
@@ -47,61 +47,61 @@ makeLenses ''SwaggerExternalDocs
47class HasDescription s d | s -> d where
47class HasDescription s d | s -> d where
48 description :: Lens' s d
48 description :: Lens' s d
49
49
50−instance HasDescription SwaggerResponse Text where description = swaggerResponseDescription
50+instance HasDescription Response Text where description = responseDescription
51−instance HasDescription SwaggerInfo (Maybe Text) where description = swaggerInfoDescription
51+instance HasDescription Info (Maybe Text) where description = infoDescription
52−instance HasDescription SwaggerTag (Maybe Text) where description = swaggerTagDescription
52+instance HasDescription Tag (Maybe Text) where description = tagDescription
53−instance HasDescription SwaggerOperation (Maybe Text) where description = swaggerOperationDescription
53+instance HasDescription Operation (Maybe Text) where description = operationDescription
54−instance HasDescription SwaggerParameter (Maybe Text) where description = swaggerParameterDescription
54+instance HasDescription Parameter (Maybe Text) where description = parameterDescription
55−instance HasDescription SwaggerHeader (Maybe Text) where description = swaggerHeaderDescription
55+instance HasDescription Header (Maybe Text) where description = headerDescription
56−instance HasDescription SwaggerSchema (Maybe Text) where description = swaggerSchemaDescription
56+instance HasDescription Schema (Maybe Text) where description = schemaDescription
57−instance HasDescription SwaggerSecurityScheme (Maybe Text) where description = swaggerSecuritySchemeDescription
57+instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
58−instance HasDescription SwaggerExternalDocs (Maybe Text) where description = swaggerExternalDocsDescription
58+instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
59
59
60−class HasSwaggerSchemaCommon s where
60+class HasSchemaCommon s where
61− schemaCommon :: Lens' s SwaggerSchemaCommon
61+ schemaCommon :: Lens' s SchemaCommon
62
62
63−instance HasSwaggerSchemaCommon SwaggerSchema where schemaCommon = swaggerSchemaCommon
63+instance HasSchemaCommon Schema where schemaCommon = schemaCommon
64−instance HasSwaggerSchemaCommon SwaggerParameterOtherSchema where schemaCommon = swaggerParameterOtherSchemaCommon
64+instance HasSchemaCommon ParameterOtherSchema where schemaCommon = parameterOtherSchemaCommon
65−instance HasSwaggerSchemaCommon SwaggerItems where schemaCommon = swaggerItemsCommon
65+instance HasSchemaCommon Items where schemaCommon = itemsCommon
66−instance HasSwaggerSchemaCommon SwaggerHeader where schemaCommon = swaggerHeaderCommon
66+instance HasSchemaCommon Header where schemaCommon = headerCommon
67−instance HasSwaggerSchemaCommon SwaggerSchemaCommon where schemaCommon = id
67+instance HasSchemaCommon SchemaCommon where schemaCommon = id
68
68
69−schemaDefault :: HasSwaggerSchemaCommon s => Lens' s (Maybe Value)
69+schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
70−schemaDefault = schemaCommon.swaggerSchemaDefault
70+schemaDefault = schemaCommon.schemaCommonDefault
71
71
72−schemaMaximum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
72+schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Integer)
73−schemaMaximum = schemaCommon.swaggerSchemaMaximum
73+schemaMaximum = schemaCommon.schemaCommonMaximum
74
74
75−schemaExclusiveMaximum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
75+schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
76−schemaExclusiveMaximum = schemaCommon.swaggerSchemaExclusiveMaximum
76+schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
77
77
78−schemaMinimum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
78+schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Integer)
79−schemaMinimum = schemaCommon.swaggerSchemaMinimum
79+schemaMinimum = schemaCommon.schemaCommonMinimum
80
80
81−schemaExclusiveMinimum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
81+schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
82−schemaExclusiveMinimum = schemaCommon.swaggerSchemaExclusiveMinimum
82+schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
83
83
84−schemaMaxLength :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
84+schemaMaxLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
85−schemaMaxLength = schemaCommon.swaggerSchemaMaxLength
85+schemaMaxLength = schemaCommon.schemaCommonMaxLength
86
86
87−schemaMinLength :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
87+schemaMinLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
88−schemaMinLength = schemaCommon.swaggerSchemaMinLength
88+schemaMinLength = schemaCommon.schemaCommonMinLength
89
89
90−schemaPattern :: HasSwaggerSchemaCommon s => Lens' s (Maybe Text)
90+schemaPattern :: HasSchemaCommon s => Lens' s (Maybe Text)
91−schemaPattern = schemaCommon.swaggerSchemaPattern
91+schemaPattern = schemaCommon.schemaCommonPattern
92
92
93−schemaMaxItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
93+schemaMaxItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
94−schemaMaxItems = schemaCommon.swaggerSchemaMaxItems
94+schemaMaxItems = schemaCommon.schemaCommonMaxItems
95
95
96−schemaMinItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
96+schemaMinItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
97−schemaMinItems = schemaCommon.swaggerSchemaMinItems
97+schemaMinItems = schemaCommon.schemaCommonMinItems
98
98
99−schemaUniqueItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
99+schemaUniqueItems :: HasSchemaCommon s => Lens' s (Maybe Bool)
100−schemaUniqueItems = schemaCommon.swaggerSchemaUniqueItems
100+schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
101
101
102−schemaEnum :: HasSwaggerSchemaCommon s => Lens' s (Maybe [Value])
102+schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
103−schemaEnum = schemaCommon.swaggerSchemaEnum
103+schemaEnum = schemaCommon.schemaCommonEnum
104
104
105−schemaMultipleOf :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
105+schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Integer)
106−schemaMultipleOf = schemaCommon.swaggerSchemaMultipleOf
106+schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107
107
test/Data/SwaggerSpec.hs+159−159
@@ -68,18 +68,18 @@ main = hspec spec
68-- Info object
68-- Info object
69-- =======================================================================
69-- =======================================================================
70
70
71−infoExample :: SwaggerInfo
71+infoExample :: Info
72−infoExample = SwaggerInfo
72+infoExample = Info
73− { _swaggerInfoTitle = "Swagger Sample App"
73+ { _infoTitle = "Swagger Sample App"
74− , _swaggerInfoDescription = Just "This is a sample server Petstore server."
74+ , _infoDescription = Just "This is a sample server Petstore server."
75− , _swaggerInfoTermsOfService = Just "http://swagger.io/terms/"
75+ , _infoTermsOfService = Just "http://swagger.io/terms/"
76− , _swaggerInfoContact = Just contactExample
76+ , _infoContact = Just contactExample
77− , _swaggerInfoLicense = Just licenseExample
77+ , _infoLicense = Just licenseExample
78− , _swaggerInfoVersion = "1.0.1" }
78+ , _infoVersion = "1.0.1" }
79 where
79 where
80− license = SwaggerLicense
80+ license = License
81− { _swaggerLicenseName = "Apache 2.0"
81+ { _licenseName = "Apache 2.0"
82− , _swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
82+ , _licenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
83
83
84infoExampleJSON :: Value
84infoExampleJSON :: Value
85infoExampleJSON = [aesonQQ|
85infoExampleJSON = [aesonQQ|
@@ -104,11 +104,11 @@ infoExampleJSON = [aesonQQ|
104-- Contact object
104-- Contact object
105-- =======================================================================
105-- =======================================================================
106
106
107−contactExample :: SwaggerContact
107+contactExample :: Contact
108−contactExample = SwaggerContact
108+contactExample = Contact
109− { _swaggerContactName = Just "API Support"
109+ { _contactName = Just "API Support"
110− , _swaggerContactUrl = Just (URL "http://www.swagger.io/support")
110+ , _contactUrl = Just (URL "http://www.swagger.io/support")
111− , _swaggerContactEmail = Just "support@swagger.io" }
111+ , _contactEmail = Just "support@swagger.io" }
112
112
113contactExampleJSON :: Value
113contactExampleJSON :: Value
114contactExampleJSON = [aesonQQ|
114contactExampleJSON = [aesonQQ|
@@ -123,10 +123,10 @@ contactExampleJSON = [aesonQQ|
123-- License object
123-- License object
124-- =======================================================================
124-- =======================================================================
125
125
126−licenseExample :: SwaggerLicense
126+licenseExample :: License
127−licenseExample = SwaggerLicense
127+licenseExample = License
128− { _swaggerLicenseName = "Apache 2.0"
128+ { _licenseName = "Apache 2.0"
129− , _swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
129+ , _licenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
130
130
131licenseExampleJSON :: Value
131licenseExampleJSON :: Value
132licenseExampleJSON = [aesonQQ|
132licenseExampleJSON = [aesonQQ|
@@ -141,47 +141,47 @@ licenseExampleJSON = [aesonQQ|
141-- Operation object
141-- Operation object
142-- =======================================================================
142-- =======================================================================
143
143
144−operationExample :: SwaggerOperation
144+operationExample :: Operation
145operationExample = mempty
145operationExample = mempty
146− { _swaggerOperationTags = ["pet"]
146+ { _operationTags = ["pet"]
147− , _swaggerOperationSummary = Just "Updates a pet in the store with form data"
147+ , _operationSummary = Just "Updates a pet in the store with form data"
148− , _swaggerOperationDescription = Just ""
148+ , _operationDescription = Just ""
149− , _swaggerOperationOperationId = Just "updatePetWithForm"
149+ , _operationOperationId = Just "updatePetWithForm"
150− , _swaggerOperationConsumes = Just (SwaggerMimeList ["application/x-www-form-urlencoded"])
150+ , _operationConsumes = Just (MimeList ["application/x-www-form-urlencoded"])
151− , _swaggerOperationProduces = Just (SwaggerMimeList ["application/json", "application/xml"])
151+ , _operationProduces = Just (MimeList ["application/json", "application/xml"])
152− , _swaggerOperationParameters = params
152+ , _operationParameters = params
153− , _swaggerOperationResponses = responses
153+ , _operationResponses = responses
154− , _swaggerOperationSecurity = security
154+ , _operationSecurity = security
155 }
155 }
156 where
156 where
157− security = [SwaggerSecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
157+ security = [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
158
158
159 responses = mempty
159 responses = mempty
160− { _swaggerResponsesResponses =
160+ { _responsesResponses =
161− [ (200, SwaggerInline mempty { _swaggerResponseDescription = "Pet updated." })
161+ [ (200, Inline mempty { _responseDescription = "Pet updated." })
162− , (405, SwaggerInline mempty { _swaggerResponseDescription = "Invalid input" }) ] }
162+ , (405, Inline mempty { _responseDescription = "Invalid input" }) ] }
163
163
164− params = map SwaggerInline
164+ params = map Inline
165− [ SwaggerParameter
165+ [ Parameter
166− { _swaggerParameterName = "petId"
166+ { _parameterName = "petId"
167− , _swaggerParameterDescription = Just "ID of pet that needs to be updated"
167+ , _parameterDescription = Just "ID of pet that needs to be updated"
168− , _swaggerParameterRequired = Just True
168+ , _parameterRequired = Just True
169− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterPath) }
169+ , _parameterSchema = ParameterOther (stringSchema ParameterPath) }
170− , SwaggerParameter
170+ , Parameter
171− { _swaggerParameterName = "name"
171+ { _parameterName = "name"
172− , _swaggerParameterDescription = Just "Updated name of the pet"
172+ , _parameterDescription = Just "Updated name of the pet"
173− , _swaggerParameterRequired = Just False
173+ , _parameterRequired = Just False
174− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterFormData) }
174+ , _parameterSchema = ParameterOther (stringSchema ParameterFormData) }
175− , SwaggerParameter
175+ , Parameter
176− { _swaggerParameterName = "status"
176+ { _parameterName = "status"
177− , _swaggerParameterDescription = Just "Updated status of the pet"
177+ , _parameterDescription = Just "Updated status of the pet"
178− , _swaggerParameterRequired = Just False
178+ , _parameterRequired = Just False
179− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterFormData) }
179+ , _parameterSchema = ParameterOther (stringSchema ParameterFormData) }
180 ]
180 ]
181
181
182 stringSchema i = mempty
182 stringSchema i = mempty
183− { _swaggerParameterOtherSchemaIn = i
183+ { _parameterOtherSchemaIn = i
184− , _swaggerParameterOtherSchemaType = SwaggerParamString
184+ , _parameterOtherSchemaType = ParamString
185 }
185 }
186
186
187operationExampleJSON :: Value
187operationExampleJSON :: Value
@@ -246,10 +246,10 @@ operationExampleJSON = [aesonQQ|
246-- Schema object
246-- Schema object
247-- =======================================================================
247-- =======================================================================
248
248
249−schemaPrimitiveExample :: SwaggerSchema
249+schemaPrimitiveExample :: Schema
250schemaPrimitiveExample = mempty
250schemaPrimitiveExample = mempty
251− { _swaggerSchemaType = SwaggerSchemaString
251+ { _schemaType = SchemaString
252− , _swaggerSchemaFormat = Just "email"
252+ , _schemaFormat = Just "email"
253 }
253 }
254
254
255schemaPrimitiveExampleJSON :: Value
255schemaPrimitiveExampleJSON :: Value
@@ -260,19 +260,19 @@ schemaPrimitiveExampleJSON = [aesonQQ|
260}
260}
261|]
261|]
262
262
263−schemaSimpleModelExample :: SwaggerSchema
263+schemaSimpleModelExample :: Schema
264schemaSimpleModelExample = mempty
264schemaSimpleModelExample = mempty
265− { _swaggerSchemaType = SwaggerSchemaObject
265+ { _schemaType = SchemaObject
266− , _swaggerSchemaRequired = [ "name" ]
266+ , _schemaRequired = [ "name" ]
267− , _swaggerSchemaProperties =
267+ , _schemaProperties =
268− [ ("name", SwaggerInline mempty
268+ [ ("name", Inline mempty
269− { _swaggerSchemaType = SwaggerSchemaString } )
269+ { _schemaType = SchemaString } )
270− , ("address", SwaggerRef (SwaggerReference "#/definitions/Address"))
270+ , ("address", Ref (Reference "#/definitions/Address"))
271− , ("age", SwaggerInline mempty
271+ , ("age", Inline mempty
272− { _swaggerSchemaType = SwaggerSchemaInteger
272+ { _schemaType = SchemaInteger
273− , _swaggerSchemaFormat = Just "int32"
273+ , _schemaFormat = Just "int32"
274− , _swaggerSchemaCommon = mempty
274+ , _schemaSchemaCommon = mempty
275− { _swaggerSchemaMinimum = Just 0 } } ) ] }
275+ { _schemaCommonMinimum = Just 0 } } ) ] }
276
276
277schemaSimpleModelExampleJSON :: Value
277schemaSimpleModelExampleJSON :: Value
278schemaSimpleModelExampleJSON = [aesonQQ|
278schemaSimpleModelExampleJSON = [aesonQQ|
@@ -297,11 +297,11 @@ schemaSimpleModelExampleJSON = [aesonQQ|
297}
297}
298|]
298|]
299
299
300−schemaModelDictExample :: SwaggerSchema
300+schemaModelDictExample :: Schema
301schemaModelDictExample = mempty
301schemaModelDictExample = mempty
302− { _swaggerSchemaType = SwaggerSchemaObject
302+ { _schemaType = SchemaObject
303− , _swaggerSchemaAdditionalProperties = Just mempty
303+ , _schemaAdditionalProperties = Just mempty
304− { _swaggerSchemaType = SwaggerSchemaString } }
304+ { _schemaType = SchemaString } }
305
305
306schemaModelDictExampleJSON :: Value
306schemaModelDictExampleJSON :: Value
307schemaModelDictExampleJSON = [aesonQQ|
307schemaModelDictExampleJSON = [aesonQQ|
@@ -313,17 +313,17 @@ schemaModelDictExampleJSON = [aesonQQ|
313}
313}
314|]
314|]
315
315
316−schemaWithExampleExample :: SwaggerSchema
316+schemaWithExampleExample :: Schema
317schemaWithExampleExample = mempty
317schemaWithExampleExample = mempty
318− { _swaggerSchemaType = SwaggerSchemaObject
318+ { _schemaType = SchemaObject
319− , _swaggerSchemaProperties =
319+ , _schemaProperties =
320− [ ("id", SwaggerInline mempty
320+ [ ("id", Inline mempty
321− { _swaggerSchemaType = SwaggerSchemaInteger
321+ { _schemaType = SchemaInteger
322− , _swaggerSchemaFormat = Just "int64" })
322+ , _schemaFormat = Just "int64" })
323− , ("name", SwaggerInline mempty
323+ , ("name", Inline mempty
324− { _swaggerSchemaType = SwaggerSchemaString }) ]
324+ { _schemaType = SchemaString }) ]
325− , _swaggerSchemaRequired = [ "name" ]
325+ , _schemaRequired = [ "name" ]
326− , _swaggerSchemaExample = Just [aesonQQ|
326+ , _schemaExample = Just [aesonQQ|
327 {
327 {
328 "name": "Puma",
328 "name": "Puma",
329 "id": 1
329 "id": 1
@@ -357,24 +357,24 @@ schemaWithExampleExampleJSON = [aesonQQ|
357-- Definitions object
357-- Definitions object
358-- =======================================================================
358-- =======================================================================
359
359
360−definitionsExample :: HashMap Text SwaggerSchema
360+definitionsExample :: HashMap Text Schema
361definitionsExample =
361definitionsExample =
362 [ ("Category", mempty
362 [ ("Category", mempty
363− { _swaggerSchemaType = SwaggerSchemaObject
363+ { _schemaType = SchemaObject
364− , _swaggerSchemaProperties =
364+ , _schemaProperties =
365− [ ("id", SwaggerInline mempty
365+ [ ("id", Inline mempty
366− { _swaggerSchemaType = SwaggerSchemaInteger
366+ { _schemaType = SchemaInteger
367− , _swaggerSchemaFormat = Just "int64" })
367+ , _schemaFormat = Just "int64" })
368− , ("name", SwaggerInline mempty
368+ , ("name", Inline mempty
369− { _swaggerSchemaType = SwaggerSchemaString }) ] })
369+ { _schemaType = SchemaString }) ] })
370 , ("Tag", mempty
370 , ("Tag", mempty
371− { _swaggerSchemaType = SwaggerSchemaObject
371+ { _schemaType = SchemaObject
372− , _swaggerSchemaProperties =
372+ , _schemaProperties =
373− [ ("id", SwaggerInline mempty
373+ [ ("id", Inline mempty
374− { _swaggerSchemaType = SwaggerSchemaInteger
374+ { _schemaType = SchemaInteger
375− , _swaggerSchemaFormat = Just "int64" })
375+ , _schemaFormat = Just "int64" })
376− , ("name", SwaggerInline mempty
376+ , ("name", Inline mempty
377− { _swaggerSchemaType = SwaggerSchemaString }) ] }) ]
377+ { _schemaType = SchemaString }) ] }) ]
378
378
379definitionsExampleJSON :: Value
379definitionsExampleJSON :: Value
380definitionsExampleJSON = [aesonQQ|
380definitionsExampleJSON = [aesonQQ|
@@ -410,24 +410,24 @@ definitionsExampleJSON = [aesonQQ|
410-- Parameters Definition object
410-- Parameters Definition object
411-- =======================================================================
411-- =======================================================================
412
412
413−parametersDefinitionExample :: HashMap Text SwaggerParameter
413+parametersDefinitionExample :: HashMap Text Parameter
414parametersDefinitionExample =
414parametersDefinitionExample =
415 [ ("skipParam", mempty
415 [ ("skipParam", mempty
416− { _swaggerParameterName = "skip"
416+ { _parameterName = "skip"
417− , _swaggerParameterDescription = Just "number of items to skip"
417+ , _parameterDescription = Just "number of items to skip"
418− , _swaggerParameterRequired = Just True
418+ , _parameterRequired = Just True
419− , _swaggerParameterSchema = SwaggerParameterOther mempty
419+ , _parameterSchema = ParameterOther mempty
420− { _swaggerParameterOtherSchemaIn = SwaggerParameterQuery
420+ { _parameterOtherSchemaIn = ParameterQuery
421− , _swaggerParameterOtherSchemaType = SwaggerParamInteger
421+ , _parameterOtherSchemaType = ParamInteger
422− , _swaggerParameterOtherSchemaFormat = Just "int32" } })
422+ , _parameterOtherSchemaFormat = Just "int32" } })
423 , ("limitParam", mempty
423 , ("limitParam", mempty
424− { _swaggerParameterName = "limit"
424+ { _parameterName = "limit"
425− , _swaggerParameterDescription = Just "max records to return"
425+ , _parameterDescription = Just "max records to return"
426− , _swaggerParameterRequired = Just True
426+ , _parameterRequired = Just True
427− , _swaggerParameterSchema = SwaggerParameterOther mempty
427+ , _parameterSchema = ParameterOther mempty
428− { _swaggerParameterOtherSchemaIn = SwaggerParameterQuery
428+ { _parameterOtherSchemaIn = ParameterQuery
429− , _swaggerParameterOtherSchemaType = SwaggerParamInteger
429+ , _parameterOtherSchemaType = ParamInteger
430− , _swaggerParameterOtherSchemaFormat = Just "int32" } }) ]
430+ , _parameterOtherSchemaFormat = Just "int32" } }) ]
431
431
432parametersDefinitionExampleJSON :: Value
432parametersDefinitionExampleJSON :: Value
433parametersDefinitionExampleJSON = [aesonQQ|
433parametersDefinitionExampleJSON = [aesonQQ|
@@ -455,10 +455,10 @@ parametersDefinitionExampleJSON = [aesonQQ|
455-- Responses Definition object
455-- Responses Definition object
456-- =======================================================================
456-- =======================================================================
457
457
458−responsesDefinitionExample :: HashMap Text SwaggerResponse
458+responsesDefinitionExample :: HashMap Text Response
459responsesDefinitionExample =
459responsesDefinitionExample =
460− [ ("NotFound", mempty { _swaggerResponseDescription = "Entity not found." })
460+ [ ("NotFound", mempty { _responseDescription = "Entity not found." })
461− , ("IllegalInput", mempty { _swaggerResponseDescription = "Illegal input for operation." }) ]
461+ , ("IllegalInput", mempty { _responseDescription = "Illegal input for operation." }) ]
462
462
463responsesDefinitionExampleJSON :: Value
463responsesDefinitionExampleJSON :: Value
464responsesDefinitionExampleJSON = [aesonQQ|
464responsesDefinitionExampleJSON = [aesonQQ|
@@ -476,18 +476,18 @@ responsesDefinitionExampleJSON = [aesonQQ|
476-- Responses Definition object
476-- Responses Definition object
477-- =======================================================================
477-- =======================================================================
478
478
479−securityDefinitionsExample :: HashMap Text SwaggerSecurityScheme
479+securityDefinitionsExample :: HashMap Text SecurityScheme
480securityDefinitionsExample =
480securityDefinitionsExample =
481− [ ("api_key", SwaggerSecurityScheme
481+ [ ("api_key", SecurityScheme
482− { _swaggerSecuritySchemeType = SwaggerSecuritySchemeApiKey (SwaggerApiKeyParams "api_key" SwaggerApiKeyHeader)
482+ { _securitySchemeType = SecuritySchemeApiKey (ApiKeyParams "api_key" ApiKeyHeader)
483− , _swaggerSecuritySchemeDescription = Nothing })
483+ , _securitySchemeDescription = Nothing })
484− , ("petstore_auth", SwaggerSecurityScheme
484+ , ("petstore_auth", SecurityScheme
485− { _swaggerSecuritySchemeType = SwaggerSecuritySchemeOAuth2 (SwaggerOAuth2Params
485+ { _securitySchemeType = SecuritySchemeOAuth2 (OAuth2Params
486− { _swaggerOAuth2Flow = SwaggerOAuth2Implicit "http://swagger.io/api/oauth/dialog"
486+ { _oauth2Flow = OAuth2Implicit "http://swagger.io/api/oauth/dialog"
487− , _swaggerOAuth2Scopes =
487+ , _oauth2Scopes =
488 [ ("write:pets", "modify pets in your account")
488 [ ("write:pets", "modify pets in your account")
489 , ("read:pets", "read your pets") ] } )
489 , ("read:pets", "read your pets") ] } )
490− , _swaggerSecuritySchemeDescription = Nothing }) ]
490+ , _securitySchemeDescription = Nothing }) ]
491
491
492securityDefinitionsExampleJSON :: Value
492securityDefinitionsExampleJSON :: Value
493securityDefinitionsExampleJSON = [aesonQQ|
493securityDefinitionsExampleJSON = [aesonQQ|
@@ -515,47 +515,47 @@ securityDefinitionsExampleJSON = [aesonQQ|
515
515
516swaggerExample :: Swagger
516swaggerExample :: Swagger
517swaggerExample = mempty
517swaggerExample = mempty
518− { _swaggerBasePath = Just "/"
518+ { _basePath = Just "/"
519− , _swaggerSchemes = Just [Http]
519+ , _schemes = Just [Http]
520− , _swaggerInfo = mempty
520+ , _info = mempty
521− { _swaggerInfoVersion = "1.0"
521+ { _infoVersion = "1.0"
522− , _swaggerInfoTitle = "Todo API"
522+ , _infoTitle = "Todo API"
523− , _swaggerInfoLicense = Just SwaggerLicense
523+ , _infoLicense = Just License
524− { _swaggerLicenseName = "MIT"
524+ { _licenseName = "MIT"
525− , _swaggerLicenseUrl = Just (URL "http://mit.com") }
525+ , _licenseUrl = Just (URL "http://mit.com") }
526− , _swaggerInfoDescription = Just "This is a an API that tests servant-swagger support for a Todo API" }
526+ , _infoDescription = Just "This is a an API that tests servant-swagger support for a Todo API" }
527− , _swaggerPaths = mempty
527+ , _paths = mempty
528− { _swaggerPathsMap =
528+ { _pathsMap =
529 [ ("/todo/{id}", mempty
529 [ ("/todo/{id}", mempty
530− { _swaggerPathItemGet = Just mempty
530+ { _pathItemGet = Just mempty
531− { _swaggerOperationResponses = mempty
531+ { _operationResponses = mempty
532− { _swaggerResponsesResponses =
532+ { _responsesResponses =
533− [ (200, SwaggerInline mempty
533+ [ (200, Inline mempty
534− { _swaggerResponseSchema = Just $ SwaggerInline mempty
534+ { _responseSchema = Just $ Inline mempty
535− { _swaggerSchemaExample = Just [aesonQQ|
535+ { _schemaExample = Just [aesonQQ|
536 {
536 {
537 "created": 100,
537 "created": 100,
538 "description": "get milk"
538 "description": "get milk"
539 } |]
539 } |]
540− , _swaggerSchemaType = SwaggerSchemaObject
540+ , _schemaType = SchemaObject
541− , _swaggerSchemaDescription = Just "This is some real Todo right here"
541+ , _schemaDescription = Just "This is some real Todo right here"
542− , _swaggerSchemaProperties =
542+ , _schemaProperties =
543− [ ("created", SwaggerInline mempty
543+ [ ("created", Inline mempty
544− { _swaggerSchemaType = SwaggerSchemaInteger
544+ { _schemaType = SchemaInteger
545− , _swaggerSchemaFormat = Just "int32" })
545+ , _schemaFormat = Just "int32" })
546− , ("description", SwaggerInline mempty
546+ , ("description", Inline mempty
547− { _swaggerSchemaType = SwaggerSchemaString }) ] }
547+ { _schemaType = SchemaString }) ] }
548− , _swaggerResponseDescription = "OK" }) ] }
548+ , _responseDescription = "OK" }) ] }
549− , _swaggerOperationProduces = Just (SwaggerMimeList [ "application/json" ])
549+ , _operationProduces = Just (MimeList [ "application/json" ])
550− , _swaggerOperationParameters =
550+ , _operationParameters =
551− [ SwaggerInline mempty
551+ [ Inline mempty
552− { _swaggerParameterRequired = Just True
552+ { _parameterRequired = Just True
553− , _swaggerParameterName = "id"
553+ , _parameterName = "id"
554− , _swaggerParameterDescription = Just "TodoId param"
554+ , _parameterDescription = Just "TodoId param"
555− , _swaggerParameterSchema = SwaggerParameterOther mempty
555+ , _parameterSchema = ParameterOther mempty
556− { _swaggerParameterOtherSchemaIn = SwaggerParameterPath
556+ { _parameterOtherSchemaIn = ParameterPath
557− , _swaggerParameterOtherSchemaType = SwaggerParamString } } ]
557+ , _parameterOtherSchemaType = ParamString } } ]
558− , _swaggerOperationTags = [ "todo" ] } }) ] } }
558+ , _operationTags = [ "todo" ] } }) ] } }
559
559
560swaggerExampleJSON :: Value
560swaggerExampleJSON :: Value
561swaggerExampleJSON = [aesonQQ|
561swaggerExampleJSON = [aesonQQ|