git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #9 from GetShopTV/no-swagger-prefix

Remove swagger prefix

commit9723dd100b170d879f1ba3e0733dcf8b9d98f18e authorNickolay Kudasov <fizruk@users.noreply.github.com> dateSun 22 Nov 2015, 00:42 (11 years ago) parent24d4040b9e298e
5 files changed+674−674
src/Data/Swagger.hs+40−40 src/Data/Swagger/Internal.hs+406−406 src/Data/Swagger/Internal/Utils.hs+3−3 src/Data/Swagger/Lens.hs+66−66 test/Data/SwaggerSpec.hs+159−159
src/Data/Swagger.hs+40−40
@@ -8,74 +8,74 @@
88module Data.Swagger (
99 -- * Swagger specification
1010 Swagger(..),
11− SwaggerHost(..),
12− SwaggerScheme(..),
11+ Host(..),
12+ Scheme(..),
1313
1414 -- * Info types
15− SwaggerInfo(..),
16− SwaggerContact(..),
17− SwaggerLicense(..),
15+ Info(..),
16+ Contact(..),
17+ License(..),
1818
1919 -- * Paths
20− SwaggerPaths(..),
21− SwaggerPathItem(..),
20+ Paths(..),
21+ PathItem(..),
2222
2323 -- * Operations
24− SwaggerTag(..),
25− SwaggerOperation(..),
24+ Tag(..),
25+ Operation(..),
2626
2727 -- * Types and formats
28− SwaggerParameterType(..),
29− SwaggerItemsType(..),
30− SwaggerSchemaType(..),
31− SwaggerFormat(..),
32− SwaggerCollectionFormat(..),
33− SwaggerItemsCollectionFormat(..),
28+ ParameterType(..),
29+ ItemsType(..),
30+ SchemaType(..),
31+ Format(..),
32+ CollectionFormat(..),
33+ ItemsCollectionFormat(..),
3434
3535 -- * Parameters
36− SwaggerParameter(..),
37− SwaggerParameterSchema(..),
38− SwaggerParameterOtherSchema(..),
39− SwaggerParameterLocation(..),
40− SwaggerParamName(..),
41− SwaggerItems(..),
42− SwaggerHeader(..),
43− SwaggerExample(..),
36+ Parameter(..),
37+ ParameterSchema(..),
38+ ParameterOtherSchema(..),
39+ ParameterLocation(..),
40+ ParamName(..),
41+ Items(..),
42+ Header(..),
43+ Example(..),
4444
4545 -- * Schema
46− SwaggerSchema(..),
47− SwaggerSchemaItems(..),
48− SwaggerSchemaCommon(..),
49− SwaggerXml(..),
46+ Schema(..),
47+ SchemaItems(..),
48+ SchemaCommon(..),
49+ Xml(..),
5050
5151 -- * Responses
52− SwaggerResponses(..),
53− SwaggerResponse(..),
52+ Responses(..),
53+ Response(..),
5454
5555 -- * Security
56− SwaggerSecurityScheme(..),
57− SwaggerSecuritySchemeType(..),
58− SwaggerSecurityRequirement(..),
56+ SecurityScheme(..),
57+ SecuritySchemeType(..),
58+ SecurityRequirement(..),
5959
6060 -- ** API key
61− SwaggerApiKeyParams(..),
62− SwaggerApiKeyLocation(..),
61+ ApiKeyParams(..),
62+ ApiKeyLocation(..),
6363
6464 -- ** OAuth2
65− SwaggerOAuth2Params(..),
66− SwaggerOAuth2Flow(..),
65+ OAuth2Params(..),
66+ OAuth2Flow(..),
6767 AuthorizationURL(..),
6868 TokenURL(..),
6969
7070 -- * External documentation
71− SwaggerExternalDocs(..),
71+ ExternalDocs(..),
7272
7373 -- * References
74− SwaggerReference(..),
75− SwaggerReferenced(..),
74+ Reference(..),
75+ Referenced(..),
7676
7777 -- * Miscellaneous
78− SwaggerMimeList(..),
78+ MimeList(..),
7979 URL(..),
8080) where
8181
src/Data/Swagger/Internal.hs+406−406
@@ -35,117 +35,117 @@ import Data.Swagger.Internal.Utils
3535data Swagger = Swagger
3636 { -- | Provides metadata about the API.
3737 -- The metadata can be used by the clients if needed.
38− _swaggerInfo :: SwaggerInfo
38+ _info :: Info
3939
4040 -- | The host (name or ip) serving the API. It MAY include a port.
4141 -- 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
4343
4444 -- | The base path on which the API is served, which is relative to the host.
4545 -- If it is not included, the API is served directly under the host.
4646 -- The value MUST start with a leading slash (/).
47− , _swaggerBasePath :: Maybe FilePath
47+ , _basePath :: Maybe FilePath
4848
4949 -- | The transfer protocol of the API.
5050 -- 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]
5252
5353 -- | A list of MIME types the APIs can consume.
5454 -- This is global to all APIs but can be overridden on specific API calls.
55− , _swaggerConsumes :: SwaggerMimeList
55+ , _consumes :: MimeList
5656
5757 -- | A list of MIME types the APIs can produce.
5858 -- This is global to all APIs but can be overridden on specific API calls.
59− , _swaggerProduces :: SwaggerMimeList
59+ , _produces :: MimeList
6060
6161 -- | The available paths and operations for the API.
62− , _swaggerPaths :: SwaggerPaths
62+ , _paths :: Paths
6363
6464 -- | An object to hold data types produced and consumed by operations.
65− , _swaggerDefinitions :: HashMap Text SwaggerSchema
65+ , _definitions :: HashMap Text Schema
6666
6767 -- | An object to hold parameters that can be used across operations.
6868 -- This property does not define global parameters for all operations.
69− , _swaggerParameters :: HashMap Text SwaggerParameter
69+ , _parameters :: HashMap Text Parameter
7070
7171 -- | An object to hold responses that can be used across operations.
7272 -- This property does not define global responses for all operations.
73− , _swaggerResponses :: HashMap Text SwaggerResponse
73+ , _responses :: HashMap Text Response
7474
7575 -- | Security scheme definitions that can be used across the specification.
76− , _swaggerSecurityDefinitions :: HashMap Text SwaggerSecurityScheme
76+ , _securityDefinitions :: HashMap Text SecurityScheme
7777
7878 -- | A declaration of which security schemes are applied for the API as a whole.
7979 -- The list of values describes alternative security schemes that can be used
8080 -- (that is, there is a logical OR between the security requirements).
8181 -- Individual operations can override this definition.
82− , _swaggerSecurity :: [SwaggerSecurityRequirement]
82+ , _security :: [SecurityRequirement]
8383
8484 -- | A list of tags used by the specification with additional metadata.
8585 -- The order of the tags can be used to reflect on their order by the parsing tools.
8686 -- Not all tags that are used by the Operation Object must be declared.
8787 -- The tags that are not declared may be organized randomly or based on the tools' logic.
8888 -- Each tag name in the list MUST be unique.
89− , _swaggerTags :: [SwaggerTag]
89+ , _tags :: [Tag]
9090
9191 -- | Additional external documentation.
92− , _swaggerExternalDocs :: Maybe SwaggerExternalDocs
92+ , _externalDocs :: Maybe ExternalDocs
9393 } deriving (Eq, Show, Generic)
9494
9595-- | The object provides metadata about the API.
9696-- The metadata can be used by the clients if needed,
9797-- and can be presented in the Swagger-UI for convenience.
98−data SwaggerInfo = SwaggerInfo
98+data Info = Info
9999 { -- | The title of the application.
100− _swaggerInfoTitle :: Text
100+ _infoTitle :: Text
101101
102102 -- | A short description of the application.
103103 -- GFM syntax can be used for rich text representation.
104− , _swaggerInfoDescription :: Maybe Text
104+ , _infoDescription :: Maybe Text
105105
106106 -- | The Terms of Service for the API.
107− , _swaggerInfoTermsOfService :: Maybe Text
107+ , _infoTermsOfService :: Maybe Text
108108
109109 -- | The contact information for the exposed API.
110− , _swaggerInfoContact :: Maybe SwaggerContact
110+ , _infoContact :: Maybe Contact
111111
112112 -- | The license information for the exposed API.
113− , _swaggerInfoLicense :: Maybe SwaggerLicense
113+ , _infoLicense :: Maybe License
114114
115115 -- | Provides the version of the application API
116116 -- (not to be confused with the specification version).
117− , _swaggerInfoVersion :: Text
117+ , _infoVersion :: Text
118118 } deriving (Eq, Show, Generic)
119119
120120-- | Contact information for the exposed API.
121−data SwaggerContact = SwaggerContact
121+data Contact = Contact
122122 { -- | The identifying name of the contact person/organization.
123− _swaggerContactName :: Maybe Text
123+ _contactName :: Maybe Text
124124
125125 -- | The URL pointing to the contact information.
126− , _swaggerContactUrl :: Maybe URL
126+ , _contactUrl :: Maybe URL
127127
128128 -- | The email address of the contact person/organization.
129− , _swaggerContactEmail :: Maybe Text
129+ , _contactEmail :: Maybe Text
130130 } deriving (Eq, Show)
131131
132132-- | License information for the exposed API.
133−data SwaggerLicense = SwaggerLicense
133+data License = License
134134 { -- | The license name used for the API.
135− _swaggerLicenseName :: Text
135+ _licenseName :: Text
136136
137137 -- | A URL to the license used for the API.
138− , _swaggerLicenseUrl :: Maybe URL
138+ , _licenseUrl :: Maybe URL
139139 } deriving (Eq, Show)
140140
141141-- | The host (name or ip) serving the API. It MAY include a port.
142−data SwaggerHost = SwaggerHost
143− { _swaggerHostName :: HostName -- ^ Host name.
144− , _swaggerHostPort :: Maybe PortNumber -- ^ Optional port.
142+data Host = Host
143+ { _hostName :: HostName -- ^ Host name.
144+ , _hostPort :: Maybe PortNumber -- ^ Optional port.
145145 } deriving (Eq, Show)
146146
147147-- | The transfer protocol of the API.
148−data SwaggerScheme
148+data Scheme
149149 = Http
150150 | Https
151151 | Ws
@@ -153,305 +153,305 @@ data SwaggerScheme
153153 deriving (Eq, Show)
154154
155155-- | The available paths and operations for the API.
156−data SwaggerPaths = SwaggerPaths
156+data Paths = Paths
157157 { -- | Holds the relative paths to the individual endpoints.
158− -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
159− _swaggerPathsMap :: HashMap FilePath SwaggerPathItem
158+ -- The path is appended to the @'basePath'@ in order to construct the full URL.
159+ _pathsMap :: HashMap FilePath PathItem
160160 } deriving (Eq, Show, Generic)
161161
162162-- | 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.
164164-- The path itself is still exposed to the documentation viewer
165165-- but they will not know which operations and parameters are available.
166−data SwaggerPathItem = SwaggerPathItem
166+data PathItem = PathItem
167167 { -- | A definition of a GET operation on this path.
168− _swaggerPathItemGet :: Maybe SwaggerOperation
168+ _pathItemGet :: Maybe Operation
169169
170170 -- | A definition of a PUT operation on this path.
171− , _swaggerPathItemPut :: Maybe SwaggerOperation
171+ , _pathItemPut :: Maybe Operation
172172
173173 -- | A definition of a POST operation on this path.
174− , _swaggerPathItemPost :: Maybe SwaggerOperation
174+ , _pathItemPost :: Maybe Operation
175175
176176 -- | A definition of a DELETE operation on this path.
177− , _swaggerPathItemDelete :: Maybe SwaggerOperation
177+ , _pathItemDelete :: Maybe Operation
178178
179179 -- | A definition of a OPTIONS operation on this path.
180− , _swaggerPathItemOptions :: Maybe SwaggerOperation
180+ , _pathItemOptions :: Maybe Operation
181181
182182 -- | A definition of a HEAD operation on this path.
183− , _swaggerPathItemHead :: Maybe SwaggerOperation
183+ , _pathItemHead :: Maybe Operation
184184
185185 -- | A definition of a PATCH operation on this path.
186− , _swaggerPathItemPatch :: Maybe SwaggerOperation
186+ , _pathItemPatch :: Maybe Operation
187187
188188 -- | A list of parameters that are applicable for all the operations described under this path.
189189 -- These parameters can be overridden at the operation level, but cannot be removed there.
190190 -- The list MUST NOT include duplicated parameters.
191191 -- A unique parameter is defined by a combination of a name and location.
192− , _swaggerPathItemParameters :: [SwaggerReferenced SwaggerParameter]
192+ , _pathItemParameters :: [Referenced Parameter]
193193 } deriving (Eq, Show, Generic)
194194
195195-- | Describes a single API operation on a path.
196−data SwaggerOperation = SwaggerOperation
196+data Operation = Operation
197197 { -- | A list of tags for API documentation control.
198198 -- Tags can be used for logical grouping of operations by resources or any other qualifier.
199− _swaggerOperationTags :: [Text]
199+ _operationTags :: [Text]
200200
201201 -- | A short summary of what the operation does.
202202 -- For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
203− , _swaggerOperationSummary :: Maybe Text
203+ , _operationSummary :: Maybe Text
204204
205205 -- | A verbose explanation of the operation behavior.
206206 -- GFM syntax can be used for rich text representation.
207− , _swaggerOperationDescription :: Maybe Text
207+ , _operationDescription :: Maybe Text
208208
209209 -- | Additional external documentation for this operation.
210− , _swaggerOperationExternalDocs :: Maybe SwaggerExternalDocs
210+ , _operationExternalDocs :: Maybe ExternalDocs
211211
212212 -- | Unique string used to identify the operation.
213213 -- The id MUST be unique among all operations described in the API.
214214 -- Tools and libraries MAY use the it to uniquely identify an operation,
215215 -- therefore, it is recommended to follow common programming naming conventions.
216− , _swaggerOperationOperationId :: Maybe Text
216+ , _operationOperationId :: Maybe Text
217217
218218 -- | A list of MIME types the operation can consume.
219− -- This overrides the @'swaggerConsumes'@.
219+ -- This overrides the @'consumes'@.
220220 -- @Just []@ MAY be used to clear the global definition.
221− , _swaggerOperationConsumes :: Maybe SwaggerMimeList
221+ , _operationConsumes :: Maybe MimeList
222222
223223 -- | A list of MIME types the operation can produce.
224− -- This overrides the @'swaggerProduces'@.
224+ -- This overrides the @'produces'@.
225225 -- @Just []@ MAY be used to clear the global definition.
226− , _swaggerOperationProduces :: Maybe SwaggerMimeList
226+ , _operationProduces :: Maybe MimeList
227227
228228 -- | 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'@,
230230 -- the new definition will override it, but can never remove it.
231231 -- The list MUST NOT include duplicated parameters.
232232 -- A unique parameter is defined by a combination of a name and location.
233− , _swaggerOperationParameters :: [SwaggerReferenced SwaggerParameter]
233+ , _operationParameters :: [Referenced Parameter]
234234
235235 -- | The list of possible responses as they are returned from executing this operation.
236− , _swaggerOperationResponses :: SwaggerResponses
236+ , _operationResponses :: Responses
237237
238238 -- | The transfer protocol for the operation.
239− -- The value overrides @'swaggerSchemes'@.
240− , _swaggerOperationSchemes :: Maybe [SwaggerScheme]
239+ -- The value overrides @'schemes'@.
240+ , _operationSchemes :: Maybe [Scheme]
241241
242242 -- | Declares this operation to be deprecated.
243243 -- Usage of the declared operation should be refrained.
244244 -- Default value is @False@.
245− , _swaggerOperationDeprecated :: Maybe Bool
245+ , _operationDeprecated :: Maybe Bool
246246
247247 -- | A declaration of which security schemes are applied for this operation.
248248 -- The list of values describes alternative security schemes that can be used
249249 -- (that is, there is a logical OR between the security requirements).
250250 -- This definition overrides any declared top-level security.
251251 -- To remove a top-level security declaration, @Just []@ can be used.
252− , _swaggerOperationSecurity :: [SwaggerSecurityRequirement]
252+ , _operationSecurity :: [SecurityRequirement]
253253 } deriving (Eq, Show, Generic)
254254
255−newtype SwaggerMimeList = SwaggerMimeList { getSwaggerMimeList :: [MediaType] }
255+newtype MimeList = MimeList { getMimeList :: [MediaType] }
256256 deriving (Eq, Show, Monoid)
257257
258258-- | Describes a single operation parameter.
259259-- A unique parameter is defined by a combination of a name and location.
260−data SwaggerParameter = SwaggerParameter
260+data Parameter = Parameter
261261 { -- | The name of the parameter.
262262 -- Parameter names are case sensitive.
263− _swaggerParameterName :: Text
263+ _parameterName :: Text
264264
265265 -- | A brief description of the parameter.
266266 -- This could contain examples of use.
267267 -- GFM syntax can be used for rich text representation.
268− , _swaggerParameterDescription :: Maybe Text
268+ , _parameterDescription :: Maybe Text
269269
270270 -- | Determines whether this parameter is mandatory.
271271 -- If the parameter is in "path", this property is required and its value MUST be true.
272272 -- Otherwise, the property MAY be included and its default value is @False@.
273− , _swaggerParameterRequired :: Maybe Bool
273+ , _parameterRequired :: Maybe Bool
274274
275275 -- | Parameter schema.
276− , _swaggerParameterSchema :: SwaggerParameterSchema
276+ , _parameterSchema :: ParameterSchema
277277 } deriving (Eq, Show, Generic)
278278
279−data SwaggerParameterSchema
280− = SwaggerParameterBody (SwaggerReferenced SwaggerSchema)
281− | SwaggerParameterOther SwaggerParameterOtherSchema
279+data ParameterSchema
280+ = ParameterBody (Referenced Schema)
281+ | ParameterOther ParameterOtherSchema
282282 deriving (Eq, Show)
283283
284−data SwaggerParameterOtherSchema = SwaggerParameterOtherSchema
284+data ParameterOtherSchema = ParameterOtherSchema
285285 { -- | The location of the parameter.
286− _swaggerParameterOtherSchemaIn :: SwaggerParameterLocation
286+ _parameterOtherSchemaIn :: ParameterLocation
287287
288288 -- | The type of the parameter.
289289 -- Since the parameter is not located at the request body,
290290 -- 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
292292 -- "multipart/form-data" or " application/x-www-form-urlencoded"
293− -- and the parameter MUST be in @'SwaggerParameterFormData'@.
294− , _swaggerParameterOtherSchemaType :: SwaggerParameterType
293+ -- and the parameter MUST be in @'ParameterFormData'@.
294+ , _parameterOtherSchemaType :: ParameterType
295295
296296 -- | The extending format for the previously mentioned type.
297− , _swaggerParameterOtherSchemaFormat :: Maybe SwaggerFormat
297+ , _parameterOtherSchemaFormat :: Maybe Format
298298
299299 -- | 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'@
301301 -- and allows you to send a parameter with a name only or an empty value.
302302 -- Default value is @False@.
303− , _swaggerParameterOtherSchemaAllowEmptyValue :: Maybe Bool
303+ , _parameterOtherSchemaAllowEmptyValue :: Maybe Bool
304304
305− -- | __Required if type is @'SwaggerParamArray'@__.
305+ -- | __Required if type is @'ParamArray'@__.
306306 -- Describes the type of items in the array.
307− , _swaggerParameterOtherSchemaItems :: Maybe SwaggerItems
307+ , _parameterOtherSchemaItems :: Maybe Items
308308
309− -- | Determines the format of the array if @'SwaggerParamArray'@ is used.
309+ -- | Determines the format of the array if @'ParamArray'@ is used.
310310 -- Default value is csv.
311− , _swaggerParameterOtherSchemaCollectionFormat :: Maybe SwaggerCollectionFormat
311+ , _parameterOtherSchemaCollectionFormat :: Maybe CollectionFormat
312312
313− , _swaggerParameterOtherSchemaCommon :: SwaggerSchemaCommon
313+ , _parameterOtherSchemaCommon :: SchemaCommon
314314 } deriving (Eq, Show, Generic)
315315
316−data SwaggerParameterType
317− = SwaggerParamString
318− | SwaggerParamNumber
319− | SwaggerParamInteger
320− | SwaggerParamBoolean
321− | SwaggerParamArray
322− | SwaggerParamFile
316+data ParameterType
317+ = ParamString
318+ | ParamNumber
319+ | ParamInteger
320+ | ParamBoolean
321+ | ParamArray
322+ | ParamFile
323323 deriving (Eq, Show)
324324
325−data SwaggerParameterLocation
325+data ParameterLocation
326326 = -- | Parameters that are appended to the URL.
327327 -- For example, in @/items?id=###@, the query parameter is @id@.
328− SwaggerParameterQuery
328+ ParameterQuery
329329 -- | Custom headers that are expected as part of the request.
330− | SwaggerParameterHeader
330+ | ParameterHeader
331331 -- | Used together with Path Templating, where the parameter value is actually part of the operation's URL.
332332 -- This does not include the host or base path of the API.
333333 -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
334− | SwaggerParameterPath
334+ | ParameterPath
335335 -- | Used to describe the payload of an HTTP request when either @application/x-www-form-urlencoded@
336336 -- or @multipart/form-data@ are used as the content type of the request
337337 -- (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.
339339 -- Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
340340 -- Form parameters have a different format based on the content-type used
341341 -- (for further details, consult <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>).
342− | SwaggerParameterFormData
342+ | ParameterFormData
343343 deriving (Eq, Show)
344344
345−type SwaggerFormat = Text
345+type Format = Text
346346
347347-- | Determines the format of the array.
348−data SwaggerCollectionFormat
349− = SwaggerCollectionCSV -- ^ Comma separated values: @foo,bar@.
350− | SwaggerCollectionSSV -- ^ Space separated values: @foo bar@.
351− | SwaggerCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
352− | SwaggerCollectionPipes -- ^ Pipe separated values: @foo|bar@.
353− | SwaggerCollectionMulti -- ^ Corresponds to multiple parameter instances
348+data CollectionFormat
349+ = CollectionCSV -- ^ Comma separated values: @foo,bar@.
350+ | CollectionSSV -- ^ Space separated values: @foo bar@.
351+ | CollectionTSV -- ^ Tab separated values: @foo\\tbar@.
352+ | CollectionPipes -- ^ Pipe separated values: @foo|bar@.
353+ | CollectionMulti -- ^ Corresponds to multiple parameter instances
354354 -- 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'@.
356356 deriving (Eq, Show)
357357
358−data SwaggerItemsType
359− = SwaggerItemsString
360− | SwaggerItemsNumber
361− | SwaggerItemsInteger
362− | SwaggerItemsBoolean
363− | SwaggerItemsArray
358+data ItemsType
359+ = ItemsString
360+ | ItemsNumber
361+ | ItemsInteger
362+ | ItemsBoolean
363+ | ItemsArray
364364 deriving (Eq, Show)
365365
366−data SwaggerSchemaType
367− = SwaggerSchemaArray
368− | SwaggerSchemaBoolean
369− | SwaggerSchemaInteger
370− | SwaggerSchemaNumber
371− | SwaggerSchemaNull
372− | SwaggerSchemaObject
373− | SwaggerSchemaString
366+data SchemaType
367+ = SchemaArray
368+ | SchemaBoolean
369+ | SchemaInteger
370+ | SchemaNumber
371+ | SchemaNull
372+ | SchemaObject
373+ | SchemaString
374374 deriving (Eq, Show)
375375
376376-- | Determines the format of the nested array.
377−data SwaggerItemsCollectionFormat
378− = SwaggerItemsCollectionCSV -- ^ Comma separated values: @foo,bar@.
379− | SwaggerItemsCollectionSSV -- ^ Space separated values: @foo bar@.
380− | SwaggerItemsCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
381− | SwaggerItemsCollectionPipes -- ^ Pipe separated values: @foo|bar@.
377+data ItemsCollectionFormat
378+ = ItemsCollectionCSV -- ^ Comma separated values: @foo,bar@.
379+ | ItemsCollectionSSV -- ^ Space separated values: @foo bar@.
380+ | ItemsCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
381+ | ItemsCollectionPipes -- ^ Pipe separated values: @foo|bar@.
382382 deriving (Eq, Show)
383383
384−type SwaggerParamName = Text
384+type ParamName = Text
385385
386−data SwaggerSchema = SwaggerSchema
387− { _swaggerSchemaType :: SwaggerSchemaType
388− , _swaggerSchemaFormat :: Maybe SwaggerFormat
389− , _swaggerSchemaTitle :: Maybe Text
390− , _swaggerSchemaDescription :: Maybe Text
391− , _swaggerSchemaRequired :: [SwaggerParamName]
386+data Schema = Schema
387+ { _schemaType :: SchemaType
388+ , _schemaFormat :: Maybe Format
389+ , _schemaTitle :: Maybe Text
390+ , _schemaDescription :: Maybe Text
391+ , _schemaRequired :: [ParamName]
392392
393− , _swaggerSchemaItems :: Maybe SwaggerSchemaItems
394− , _swaggerSchemaAllOf :: Maybe [SwaggerSchema]
395− , _swaggerSchemaProperties :: HashMap Text (SwaggerReferenced SwaggerSchema)
396− , _swaggerSchemaAdditionalProperties :: Maybe SwaggerSchema
393+ , _schemaItems :: Maybe SchemaItems
394+ , _schemaAllOf :: Maybe [Schema]
395+ , _schemaProperties :: HashMap Text (Referenced Schema)
396+ , _schemaAdditionalProperties :: Maybe Schema
397397
398− , _swaggerSchemaDiscriminator :: Maybe Text
399− , _swaggerSchemaReadOnly :: Maybe Bool
400− , _swaggerSchemaXml :: Maybe SwaggerXml
401− , _swaggerSchemaExternalDocs :: Maybe SwaggerExternalDocs
402− , _swaggerSchemaExample :: Maybe Value
398+ , _schemaDiscriminator :: Maybe Text
399+ , _schemaReadOnly :: Maybe Bool
400+ , _schemaXml :: Maybe Xml
401+ , _schemaExternalDocs :: Maybe ExternalDocs
402+ , _schemaExample :: Maybe Value
403403
404− , _swaggerSchemaMaxProperties :: Maybe Integer
405− , _swaggerSchemaMinProperties :: Maybe Integer
404+ , _schemaMaxProperties :: Maybe Integer
405+ , _schemaMinProperties :: Maybe Integer
406406
407− , _swaggerSchemaCommon :: SwaggerSchemaCommon
407+ , _schemaSchemaCommon :: SchemaCommon
408408 } deriving (Eq, Show, Generic)
409409
410−data SwaggerSchemaItems
411− = SwaggerSchemaItemsObject (SwaggerReferenced SwaggerSchema)
412− | SwaggerSchemaItemsArray [SwaggerReferenced SwaggerSchema]
410+data SchemaItems
411+ = SchemaItemsObject (Referenced Schema)
412+ | SchemaItemsArray [Referenced Schema]
413413 deriving (Eq, Show)
414414
415−data SwaggerSchemaCommon = SwaggerSchemaCommon
415+data SchemaCommon = SchemaCommon
416416 { -- | Declares the value of the parameter that the server will use if none is provided,
417417 -- for example a @"count"@ to control the number of results per page might default to @100@
418418 -- if not supplied by the client in the request.
419419 -- (Note: "default" has no meaning for required parameters.)
420420 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
421− _swaggerSchemaDefault :: Maybe Value
422−
423− , _swaggerSchemaMaximum :: Maybe Integer
424− , _swaggerSchemaExclusiveMaximum :: Maybe Bool
425− , _swaggerSchemaMinimum :: Maybe Integer
426− , _swaggerSchemaExclusiveMinimum :: Maybe Bool
427− , _swaggerSchemaMaxLength :: Maybe Integer
428− , _swaggerSchemaMinLength :: Maybe Integer
429− , _swaggerSchemaPattern :: Maybe Text
430− , _swaggerSchemaMaxItems :: Maybe Integer
431− , _swaggerSchemaMinItems :: Maybe Integer
432− , _swaggerSchemaUniqueItems :: Maybe Bool
433− , _swaggerSchemaEnum :: Maybe [Value]
434− , _swaggerSchemaMultipleOf :: Maybe Integer
421+ _schemaCommonDefault :: Maybe Value
422+
423+ , _schemaCommonMaximum :: Maybe Integer
424+ , _schemaCommonExclusiveMaximum :: Maybe Bool
425+ , _schemaCommonMinimum :: Maybe Integer
426+ , _schemaCommonExclusiveMinimum :: Maybe Bool
427+ , _schemaCommonMaxLength :: Maybe Integer
428+ , _schemaCommonMinLength :: Maybe Integer
429+ , _schemaCommonPattern :: Maybe Text
430+ , _schemaCommonMaxItems :: Maybe Integer
431+ , _schemaCommonMinItems :: Maybe Integer
432+ , _schemaCommonUniqueItems :: Maybe Bool
433+ , _schemaCommonEnum :: Maybe [Value]
434+ , _schemaCommonMultipleOf :: Maybe Integer
435435 } deriving (Eq, Show, Generic)
436436
437−data SwaggerXml = SwaggerXml
437+data Xml = Xml
438438 { -- | 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.
440440 -- When defined alongside type being array (outside the items),
441441 -- it will affect the wrapping element and only if wrapped is true.
442442 -- If wrapped is false, it will be ignored.
443− _swaggerXmlName :: Maybe Text
443+ _xmlName :: Maybe Text
444444
445445 -- | The URL of the namespace definition.
446446 -- Value SHOULD be in the form of a URL.
447− , _swaggerXmlNamespace :: Maybe Text
447+ , _xmlNamespace :: Maybe Text
448448
449449 -- | The prefix to be used for the name.
450− , _swaggerXmlPrefix :: Maybe Text
450+ , _xmlPrefix :: Maybe Text
451451
452452 -- | Declares whether the property definition translates to an attribute instead of an element.
453453 -- Default value is @False@.
454− , _swaggerXmlAttribute :: Maybe Bool
454+ , _xmlAttribute :: Maybe Bool
455455
456456 -- | MAY be used only for an array definition.
457457 -- Signifies whether the array is wrapped
@@ -459,25 +459,25 @@ data SwaggerXml = SwaggerXml
459459 -- or unwrapped (@\<book/\>\<book/\>@).
460460 -- Default value is @False@.
461461 -- The definition takes effect only when defined alongside type being array (outside the items).
462− , _swaggerXmlWrapped :: Maybe Bool
462+ , _xmlWrapped :: Maybe Bool
463463 } deriving (Eq, Show, Generic)
464464
465−data SwaggerItems = SwaggerItems
465+data Items = Items
466466 { -- | The internal type of the array.
467− _swaggerItemsType :: SwaggerItemsType
467+ _itemsType :: ItemsType
468468
469469 -- | The extending format for the previously mentioned type.
470− , _swaggerItemsFormat :: Maybe SwaggerFormat
470+ , _itemsFormat :: Maybe Format
471471
472− -- | __Required if type is @'SwaggerItemsArray'@.__
472+ -- | __Required if type is @'ItemsArray'@.__
473473 -- Describes the type of items in the array.
474− , _swaggerItemsItems :: Maybe SwaggerItems
474+ , _itemsItems :: Maybe Items
475475
476476 -- | Determines the format of the array if type array is used.
477− -- Default value is @'SwaggerItemsCollectionCSV'@.
478− , _swaggerItemsCollectionFormat :: Maybe SwaggerItemsCollectionFormat
477+ -- Default value is @'ItemsCollectionCSV'@.
478+ , _itemsCollectionFormat :: Maybe ItemsCollectionFormat
479479
480− , _swaggerItemsCommon :: SwaggerSchemaCommon
480+ , _itemsCommon :: SchemaCommon
481481 } deriving (Eq, Show, Generic)
482482
483483-- | A container for the expected responses of an operation.
@@ -485,76 +485,76 @@ data SwaggerItems = SwaggerItems
485485-- It is not expected from the documentation to necessarily cover all possible HTTP response codes,
486486-- since they may not be known in advance.
487487-- 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
489489 { -- | The documentation of responses other than the ones declared for specific HTTP response codes.
490490 -- It can be used to cover undeclared responses.
491− _swaggerResponsesDefault :: Maybe (SwaggerReferenced SwaggerResponse)
491+ _responsesDefault :: Maybe (Referenced Response)
492492
493493 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
494494 -- Describes the expected response for those HTTP status codes.
495− , _swaggerResponsesResponses :: HashMap HttpStatusCode (SwaggerReferenced SwaggerResponse)
495+ , _responsesResponses :: HashMap HttpStatusCode (Referenced Response)
496496 } deriving (Eq, Show, Generic)
497497
498498type HttpStatusCode = Int
499499
500500-- | Describes a single response from an API Operation.
501−data SwaggerResponse = SwaggerResponse
501+data Response = Response
502502 { -- | A short description of the response.
503503 -- GFM syntax can be used for rich text representation.
504− _swaggerResponseDescription :: Text
504+ _responseDescription :: Text
505505
506506 -- | A definition of the response structure.
507507 -- It can be a primitive, an array or an object.
508508 -- If this field does not exist, it means no content is returned as part of the response.
509509 -- As an extension to the Schema Object, its root type value may also be "file".
510510 -- This SHOULD be accompanied by a relevant produces mime-type.
511− , _swaggerResponseSchema :: Maybe (SwaggerReferenced SwaggerSchema)
511+ , _responseSchema :: Maybe (Referenced Schema)
512512
513513 -- | A list of headers that are sent with the response.
514− , _swaggerResponseHeaders :: HashMap HeaderName SwaggerHeader
514+ , _responseHeaders :: HashMap HeaderName Header
515515
516516 -- | An example of the response message.
517− , _swaggerResponseExamples :: Maybe SwaggerExample
517+ , _responseExamples :: Maybe Example
518518 } deriving (Eq, Show, Generic)
519519
520520type HeaderName = Text
521521
522−data SwaggerHeader = SwaggerHeader
522+data Header = Header
523523 { -- | A short description of the header.
524− _swaggerHeaderDescription :: Maybe Text
524+ _headerDescription :: Maybe Text
525525
526526 -- | The type of the object.
527− , _swaggerHeaderType :: SwaggerItemsType
527+ , _headerType :: ItemsType
528528
529529 -- | The extending format for the previously mentioned type. See Data Type Formats for further details.
530− , _swaggerHeaderFormat :: Maybe SwaggerFormat
530+ , _headerFormat :: Maybe Format
531531
532− -- | __Required if type is @'SwaggerItemsArray'@__.
532+ -- | __Required if type is @'ItemsArray'@__.
533533 -- Describes the type of items in the array.
534− , _swaggerHeaderItems :: Maybe SwaggerItems
534+ , _headerItems :: Maybe Items
535535
536536 -- | Determines the format of the array if type array is used.
537− -- Default value is @'SwaggerItemsCollectionCSV'@.
538− , _swaggerHeaderCollectionFormat :: Maybe SwaggerItemsCollectionFormat
537+ -- Default value is @'ItemsCollectionCSV'@.
538+ , _headerCollectionFormat :: Maybe ItemsCollectionFormat
539539
540− , _swaggerHeaderCommon :: SwaggerSchemaCommon
540+ , _headerCommon :: SchemaCommon
541541 } deriving (Eq, Show, Generic)
542542
543−data SwaggerExample = SwaggerExample { getSwaggerExample :: Map MediaType Value }
543+data Example = Example { getExample :: Map MediaType Value }
544544 deriving (Eq, Show)
545545
546546-- | The location of the API key.
547−data SwaggerApiKeyLocation
548− = SwaggerApiKeyQuery
549− | SwaggerApiKeyHeader
547+data ApiKeyLocation
548+ = ApiKeyQuery
549+ | ApiKeyHeader
550550 deriving (Eq, Show)
551551
552−data SwaggerApiKeyParams = SwaggerApiKeyParams
552+data ApiKeyParams = ApiKeyParams
553553 { -- | The name of the header or query parameter to be used.
554− _swaggerApiKeyName :: Text
554+ _apiKeyName :: Text
555555
556556 -- | The location of the API key.
557− , _swaggerApiKeyIn :: SwaggerApiKeyLocation
557+ , _apiKeyIn :: ApiKeyLocation
558558 } deriving (Eq, Show)
559559
560560-- | 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
563563-- | The token URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.
564564type TokenURL = Text
565565
566−data SwaggerOAuth2Flow
567− = SwaggerOAuth2Implicit AuthorizationURL
568− | SwaggerOAuth2Password TokenURL
569− | SwaggerOAuth2Application TokenURL
570− | SwaggerOAuth2AccessCode AuthorizationURL TokenURL
566+data OAuth2Flow
567+ = OAuth2Implicit AuthorizationURL
568+ | OAuth2Password TokenURL
569+ | OAuth2Application TokenURL
570+ | OAuth2AccessCode AuthorizationURL TokenURL
571571 deriving (Eq, Show)
572572
573−data SwaggerOAuth2Params = SwaggerOAuth2Params
573+data OAuth2Params = OAuth2Params
574574 { -- | The flow used by the OAuth2 security scheme.
575− _swaggerOAuth2Flow :: SwaggerOAuth2Flow
575+ _oauth2Flow :: OAuth2Flow
576576
577577 -- | The available scopes for the OAuth2 security scheme.
578− , _swaggerOAuth2Scopes :: HashMap Text Text
578+ , _oauth2Scopes :: HashMap Text Text
579579 } deriving (Eq, Show, Generic)
580580
581−data SwaggerSecuritySchemeType
582− = SwaggerSecuritySchemeBasic
583− | SwaggerSecuritySchemeApiKey SwaggerApiKeyParams
584− | SwaggerSecuritySchemeOAuth2 SwaggerOAuth2Params
581+data SecuritySchemeType
582+ = SecuritySchemeBasic
583+ | SecuritySchemeApiKey ApiKeyParams
584+ | SecuritySchemeOAuth2 OAuth2Params
585585 deriving (Eq, Show)
586586
587−data SwaggerSecurityScheme = SwaggerSecurityScheme
587+data SecurityScheme = SecurityScheme
588588 { -- | The type of the security scheme.
589− _swaggerSecuritySchemeType :: SwaggerSecuritySchemeType
589+ _securitySchemeType :: SecuritySchemeType
590590
591591 -- | A short description for security scheme.
592− , _swaggerSecuritySchemeDescription :: Maybe Text
592+ , _securitySchemeDescription :: Maybe Text
593593 } deriving (Eq, Show, Generic)
594594
595595-- | Lists the required security schemes to execute this operation.
596596-- The object can have multiple security schemes declared in it which are all required
597597-- (that is, there is a logical AND between the schemes).
598−newtype SwaggerSecurityRequirement = SwaggerSecurityRequirement
599− { getSwaggerSecurityRequirement :: HashMap Text [Text]
598+newtype SecurityRequirement = SecurityRequirement
599+ { getSecurityRequirement :: HashMap Text [Text]
600600 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON)
601601
602−-- | Allows adding meta data to a single tag that is used by @SwaggerOperation@.
603−-- It is not mandatory to have a @SwaggerTag@ per tag used there.
604−data SwaggerTag = SwaggerTag
602+-- | Allows adding meta data to a single tag that is used by @Operation@.
603+-- It is not mandatory to have a @Tag@ per tag used there.
604+data Tag = Tag
605605 { -- | The name of the tag.
606− _swaggerTagName :: Text
606+ _tagName :: Text
607607
608608 -- | A short description for the tag.
609609 -- GFM syntax can be used for rich text representation.
610− , _swaggerTagDescription :: Maybe Text
610+ , _tagDescription :: Maybe Text
611611
612612 -- | Additional external documentation for this tag.
613− , _swaggerTagExternalDocs :: Maybe SwaggerExternalDocs
613+ , _tagExternalDocs :: Maybe ExternalDocs
614614 } deriving (Eq, Show)
615615
616616-- | Allows referencing an external resource for extended documentation.
617−data SwaggerExternalDocs = SwaggerExternalDocs
617+data ExternalDocs = ExternalDocs
618618 { -- | A short description of the target documentation.
619619 -- GFM syntax can be used for rich text representation.
620− _swaggerExternalDocsDescription :: Maybe Text
620+ _externalDocsDescription :: Maybe Text
621621
622622 -- | The URL for the target documentation.
623− , _swaggerExternalDocsUrl :: URL
623+ , _externalDocsUrl :: URL
624624 } deriving (Eq, Show, Generic)
625625
626626-- | A simple object to allow referencing other definitions in the specification.
627627-- 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 }
629629 deriving (Eq, Show)
630630
631−data SwaggerReferenced a
632− = SwaggerRef SwaggerReference
633− | SwaggerInline a
631+data Referenced a
632+ = Ref Reference
633+ | Inline a
634634 deriving (Eq, Show)
635635
636636newtype URL = URL { getUrl :: Text } deriving (Eq, Show, ToJSON, FromJSON)
@@ -643,47 +643,47 @@ instance Monoid Swagger where
643643 mempty = genericMempty
644644 mappend = genericMappend
645645
646−instance Monoid SwaggerInfo where
646+instance Monoid Info where
647647 mempty = genericMempty
648648 mappend = genericMappend
649649
650−instance Monoid SwaggerPaths where
650+instance Monoid Paths where
651651 mempty = genericMempty
652652 mappend = genericMappend
653653
654−instance Monoid SwaggerPathItem where
654+instance Monoid PathItem where
655655 mempty = genericMempty
656656 mappend = genericMappend
657657
658−instance Monoid SwaggerSchema where
658+instance Monoid Schema where
659659 mempty = genericMempty
660660 mappend = genericMappend
661661
662−instance Monoid SwaggerSchemaCommon where
662+instance Monoid SchemaCommon where
663663 mempty = genericMempty
664664 mappend = genericMappend
665665
666−instance Monoid SwaggerParameter where
666+instance Monoid Parameter where
667667 mempty = genericMempty
668668 mappend = genericMappend
669669
670−instance Monoid SwaggerParameterOtherSchema where
670+instance Monoid ParameterOtherSchema where
671671 mempty = genericMempty
672672 mappend = genericMappend
673673
674−instance Monoid SwaggerResponses where
674+instance Monoid Responses where
675675 mempty = genericMempty
676676 mappend = genericMappend
677677
678−instance Monoid SwaggerResponse where
678+instance Monoid Response where
679679 mempty = genericMempty
680680 mappend = genericMappend
681681
682−instance Monoid SwaggerExternalDocs where
682+instance Monoid ExternalDocs where
683683 mempty = genericMempty
684684 mappend = genericMappend
685685
686−instance Monoid SwaggerOperation where
686+instance Monoid Operation where
687687 mempty = genericMempty
688688 mappend = genericMappend
689689
@@ -691,217 +691,217 @@ instance Monoid SwaggerOperation where
691691-- SwaggerMonoid helper instances
692692-- =======================================================================
693693
694−instance SwaggerMonoid SwaggerInfo
695−instance SwaggerMonoid SwaggerPaths
696−instance SwaggerMonoid SwaggerPathItem
697−instance SwaggerMonoid SwaggerSchema
698−instance SwaggerMonoid SwaggerSchemaCommon
699−instance SwaggerMonoid SwaggerParameter
700−instance SwaggerMonoid SwaggerParameterOtherSchema
701−instance SwaggerMonoid SwaggerResponses
702−instance SwaggerMonoid SwaggerResponse
703−instance SwaggerMonoid SwaggerExternalDocs
704−instance SwaggerMonoid SwaggerOperation
705−
706−instance SwaggerMonoid SwaggerMimeList
694+instance SwaggerMonoid Info
695+instance SwaggerMonoid Paths
696+instance SwaggerMonoid PathItem
697+instance SwaggerMonoid Schema
698+instance SwaggerMonoid SchemaCommon
699+instance SwaggerMonoid Parameter
700+instance SwaggerMonoid ParameterOtherSchema
701+instance SwaggerMonoid Responses
702+instance SwaggerMonoid Response
703+instance SwaggerMonoid ExternalDocs
704+instance SwaggerMonoid Operation
705+
706+instance SwaggerMonoid MimeList
707707deriving instance SwaggerMonoid URL
708708
709−instance SwaggerMonoid SwaggerSchemaType where
710− swaggerMempty = SwaggerSchemaNull
709+instance SwaggerMonoid SchemaType where
710+ swaggerMempty = SchemaNull
711711 swaggerMappend _ y = y
712712
713−instance SwaggerMonoid SwaggerParameterType where
714− swaggerMempty = SwaggerParamString
713+instance SwaggerMonoid ParameterType where
714+ swaggerMempty = ParamString
715715 swaggerMappend _ y = y
716716
717−instance SwaggerMonoid SwaggerParameterLocation where
718− swaggerMempty = SwaggerParameterQuery
717+instance SwaggerMonoid ParameterLocation where
718+ swaggerMempty = ParameterQuery
719719 swaggerMappend _ y = y
720720
721−instance SwaggerMonoid (HashMap Text SwaggerSchema) where
721+instance SwaggerMonoid (HashMap Text Schema) where
722722 swaggerMempty = HashMap.empty
723723 swaggerMappend = HashMap.unionWith mappend
724724
725−instance SwaggerMonoid (HashMap Text (SwaggerReferenced SwaggerSchema)) where
725+instance SwaggerMonoid (HashMap Text (Referenced Schema)) where
726726 swaggerMempty = HashMap.empty
727727 swaggerMappend = HashMap.unionWith swaggerMappend
728728
729−instance Monoid a => SwaggerMonoid (SwaggerReferenced a) where
730− swaggerMempty = SwaggerInline mempty
731− swaggerMappend (SwaggerInline x) (SwaggerInline y) = SwaggerInline (x <> y)
729+instance Monoid a => SwaggerMonoid (Referenced a) where
730+ swaggerMempty = Inline mempty
731+ swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
732732 swaggerMappend _ y = y
733733
734−instance SwaggerMonoid (HashMap Text SwaggerParameter) where
734+instance SwaggerMonoid (HashMap Text Parameter) where
735735 swaggerMempty = HashMap.empty
736736 swaggerMappend = HashMap.unionWith mappend
737737
738−instance SwaggerMonoid (HashMap Text SwaggerResponse) where
738+instance SwaggerMonoid (HashMap Text Response) where
739739 swaggerMempty = HashMap.empty
740740 swaggerMappend = flip HashMap.union
741741
742−instance SwaggerMonoid (HashMap Text SwaggerSecurityScheme) where
742+instance SwaggerMonoid (HashMap Text SecurityScheme) where
743743 swaggerMempty = HashMap.empty
744744 swaggerMappend = flip HashMap.union
745745
746−instance SwaggerMonoid (HashMap FilePath SwaggerPathItem) where
746+instance SwaggerMonoid (HashMap FilePath PathItem) where
747747 swaggerMempty = HashMap.empty
748748 swaggerMappend = HashMap.unionWith mappend
749749
750−instance SwaggerMonoid (HashMap HeaderName SwaggerHeader) where
750+instance SwaggerMonoid (HashMap HeaderName Header) where
751751 swaggerMempty = HashMap.empty
752752 swaggerMappend = flip HashMap.union
753753
754−instance SwaggerMonoid (HashMap HttpStatusCode (SwaggerReferenced SwaggerResponse)) where
754+instance SwaggerMonoid (HashMap HttpStatusCode (Referenced Response)) where
755755 swaggerMempty = HashMap.empty
756756 swaggerMappend = flip HashMap.union
757757
758−instance SwaggerMonoid SwaggerParameterSchema where
759− swaggerMempty = SwaggerParameterOther swaggerMempty
760− swaggerMappend (SwaggerParameterBody x) (SwaggerParameterBody y) = SwaggerParameterBody (swaggerMappend x y)
761− swaggerMappend (SwaggerParameterOther x) (SwaggerParameterOther y) = SwaggerParameterOther (swaggerMappend x y)
758+instance SwaggerMonoid ParameterSchema where
759+ swaggerMempty = ParameterOther swaggerMempty
760+ swaggerMappend (ParameterBody x) (ParameterBody y) = ParameterBody (swaggerMappend x y)
761+ swaggerMappend (ParameterOther x) (ParameterOther y) = ParameterOther (swaggerMappend x y)
762762 swaggerMappend _ y = y
763763
764764-- =======================================================================
765765-- TH derived ToJSON and FromJSON instances
766766-- =======================================================================
767767
768−deriveJSON (jsonPrefix "SwaggerParameter") ''SwaggerParameterLocation
769−deriveJSON (jsonPrefix "SwaggerParam") ''SwaggerParameterType
770−deriveJSON' ''SwaggerInfo
771−deriveJSON' ''SwaggerContact
772−deriveJSON' ''SwaggerLicense
773−deriveJSON (jsonPrefix "SwaggerSchema") ''SwaggerSchemaType
774−deriveJSON (jsonPrefix "SwaggerItems") ''SwaggerItemsType
775−deriveJSON (jsonPrefix "SwaggerItemsCollection") ''SwaggerItemsCollectionFormat
776−deriveJSON (jsonPrefix "SwaggerCollection") ''SwaggerCollectionFormat
777−deriveJSON (jsonPrefix "SwaggerApiKey") ''SwaggerApiKeyLocation
778−deriveJSON (jsonPrefix "swaggerApiKey") ''SwaggerApiKeyParams
779−deriveJSON (jsonPrefix "swaggerSchema") ''SwaggerSchemaCommon
780−deriveJSONDefault ''SwaggerScheme
781−deriveJSON' ''SwaggerTag
782−deriveJSON' ''SwaggerExternalDocs
783−
784−deriveToJSON' ''SwaggerOperation
785−deriveToJSON' ''SwaggerResponse
786−deriveToJSON' ''SwaggerPathItem
787−deriveToJSON' ''SwaggerXml
768+deriveJSON (jsonPrefix "Parameter") ''ParameterLocation
769+deriveJSON (jsonPrefix "Param") ''ParameterType
770+deriveJSON' ''Info
771+deriveJSON' ''Contact
772+deriveJSON' ''License
773+deriveJSON (jsonPrefix "Schema") ''SchemaType
774+deriveJSON (jsonPrefix "Items") ''ItemsType
775+deriveJSON (jsonPrefix "ItemsCollection") ''ItemsCollectionFormat
776+deriveJSON (jsonPrefix "Collection") ''CollectionFormat
777+deriveJSON (jsonPrefix "ApiKey") ''ApiKeyLocation
778+deriveJSON (jsonPrefix "apiKey") ''ApiKeyParams
779+deriveJSON' ''SchemaCommon
780+deriveJSONDefault ''Scheme
781+deriveJSON' ''Tag
782+deriveJSON' ''ExternalDocs
783+
784+deriveToJSON' ''Operation
785+deriveToJSON' ''Response
786+deriveToJSON' ''PathItem
787+deriveToJSON' ''Xml
788788
789789-- =======================================================================
790790-- Manual ToJSON instances
791791-- =======================================================================
792792
793−instance ToJSON SwaggerOAuth2Flow where
794− toJSON (SwaggerOAuth2Implicit authUrl) = object
793+instance ToJSON OAuth2Flow where
794+ toJSON (OAuth2Implicit authUrl) = object
795795 [ "flow" .= ("implicit" :: Text)
796796 , "authorizationUrl" .= authUrl ]
797− toJSON (SwaggerOAuth2Password tokenUrl) = object
797+ toJSON (OAuth2Password tokenUrl) = object
798798 [ "flow" .= ("password" :: Text)
799799 , "tokenUrl" .= tokenUrl ]
800− toJSON (SwaggerOAuth2Application tokenUrl) = object
800+ toJSON (OAuth2Application tokenUrl) = object
801801 [ "flow" .= ("application" :: Text)
802802 , "tokenUrl" .= tokenUrl ]
803− toJSON (SwaggerOAuth2AccessCode authUrl tokenUrl) = object
803+ toJSON (OAuth2AccessCode authUrl tokenUrl) = object
804804 [ "flow" .= ("accessCode" :: Text)
805805 , "authorizationUrl" .= authUrl
806806 , "tokenUrl" .= tokenUrl ]
807807
808−instance ToJSON SwaggerOAuth2Params where
809− toJSON = genericToJSONWithSub "flow" (jsonPrefix "swaggerOAuth2")
808+instance ToJSON OAuth2Params where
809+ toJSON = genericToJSONWithSub "flow" (jsonPrefix "oauth2")
810810
811−instance ToJSON SwaggerSecuritySchemeType where
812− toJSON SwaggerSecuritySchemeBasic
811+instance ToJSON SecuritySchemeType where
812+ toJSON SecuritySchemeBasic
813813 = object [ "type" .= ("basic" :: Text) ]
814− toJSON (SwaggerSecuritySchemeApiKey params)
814+ toJSON (SecuritySchemeApiKey params)
815815 = toJSON params
816816 <+> object [ "type" .= ("apiKey" :: Text) ]
817− toJSON (SwaggerSecuritySchemeOAuth2 params)
817+ toJSON (SecuritySchemeOAuth2 params)
818818 = toJSON params
819819 <+> object [ "type" .= ("oauth2" :: Text) ]
820820
821821instance ToJSON Swagger where
822− toJSON = addVersion . genericToJSON (jsonPrefix "swagger")
822+ toJSON = addVersion . genericToJSON (jsonPrefix "")
823823 where
824824 addVersion (Object o) = Object (HashMap.insert "swagger" "2.0" o)
825825 addVersion _ = error "impossible"
826826
827−instance ToJSON SwaggerSecurityScheme where
828− toJSON = genericToJSONWithSub "type" (jsonPrefix "swaggerSecurityScheme")
827+instance ToJSON SecurityScheme where
828+ toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
829829
830−instance ToJSON SwaggerSchema where
831− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerSchema")
830+instance ToJSON Schema where
831+ toJSON = genericToJSONWithSub "schemaCommon" (jsonPrefix "schema")
832832
833−instance ToJSON SwaggerHeader where
834− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerHeader")
833+instance ToJSON Header where
834+ toJSON = genericToJSONWithSub "common" (jsonPrefix "header")
835835
836−instance ToJSON SwaggerItems where
837− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerItems")
836+instance ToJSON Items where
837+ toJSON = genericToJSONWithSub "common" (jsonPrefix "items")
838838
839−instance ToJSON SwaggerHost where
840− toJSON (SwaggerHost host mport) = toJSON $
839+instance ToJSON Host where
840+ toJSON (Host host mport) = toJSON $
841841 case mport of
842842 Nothing -> host
843843 Just port -> host ++ ":" ++ show port
844844
845−instance ToJSON SwaggerPaths where
846− toJSON (SwaggerPaths m) = toJSON m
845+instance ToJSON Paths where
846+ toJSON (Paths m) = toJSON m
847847
848−instance ToJSON SwaggerMimeList where
849− toJSON (SwaggerMimeList xs) = toJSON (map show xs)
848+instance ToJSON MimeList where
849+ toJSON (MimeList xs) = toJSON (map show xs)
850850
851−instance ToJSON SwaggerParameter where
852− toJSON = genericToJSONWithSub "schema" (jsonPrefix "swaggerParameter")
851+instance ToJSON Parameter where
852+ toJSON = genericToJSONWithSub "schema" (jsonPrefix "parameter")
853853
854−instance ToJSON SwaggerParameterSchema where
855− toJSON (SwaggerParameterBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
856− toJSON (SwaggerParameterOther s) = toJSON s
854+instance ToJSON ParameterSchema where
855+ toJSON (ParameterBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
856+ toJSON (ParameterOther s) = toJSON s
857857
858−instance ToJSON SwaggerParameterOtherSchema where
859− toJSON = genericToJSONWithSub "common" (jsonPrefix "swaggerParameterOtherSchema")
858+instance ToJSON ParameterOtherSchema where
859+ toJSON = genericToJSONWithSub "common" (jsonPrefix "parameterOtherSchema")
860860
861−instance ToJSON SwaggerSchemaItems where
862− toJSON (SwaggerSchemaItemsObject x) = toJSON x
863− toJSON (SwaggerSchemaItemsArray xs) = toJSON xs
861+instance ToJSON SchemaItems where
862+ toJSON (SchemaItemsObject x) = toJSON x
863+ toJSON (SchemaItemsArray xs) = toJSON xs
864864
865−instance ToJSON SwaggerResponses where
866− toJSON (SwaggerResponses def rs) = toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
865+instance ToJSON Responses where
866+ toJSON (Responses def rs) = toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
867867
868−instance ToJSON SwaggerExample where
869− toJSON = toJSON . Map.mapKeys show . getSwaggerExample
868+instance ToJSON Example where
869+ toJSON = toJSON . Map.mapKeys show . getExample
870870
871−instance ToJSON SwaggerReference where
872− toJSON (SwaggerReference ref) = object [ "$ref" .= ref ]
871+instance ToJSON Reference where
872+ toJSON (Reference ref) = object [ "$ref" .= ref ]
873873
874−instance ToJSON a => ToJSON (SwaggerReferenced a) where
875− toJSON (SwaggerRef ref) = toJSON ref
876− toJSON (SwaggerInline x) = toJSON x
874+instance ToJSON a => ToJSON (Referenced a) where
875+ toJSON (Ref ref) = toJSON ref
876+ toJSON (Inline x) = toJSON x
877877
878878-- =======================================================================
879879-- Manual FromJSON instances
880880-- =======================================================================
881881
882−instance FromJSON SwaggerOAuth2Flow where
882+instance FromJSON OAuth2Flow where
883883 parseJSON (Object o) = do
884884 (flow :: Text) <- o .: "flow"
885885 case flow of
886− "implicit" -> SwaggerOAuth2Implicit <$> o .: "authorizationUrl"
887− "password" -> SwaggerOAuth2Password <$> o .: "tokenUrl"
888− "application" -> SwaggerOAuth2Application <$> o .: "tokenUrl"
889− "accessCode" -> SwaggerOAuth2AccessCode
886+ "implicit" -> OAuth2Implicit <$> o .: "authorizationUrl"
887+ "password" -> OAuth2Password <$> o .: "tokenUrl"
888+ "application" -> OAuth2Application <$> o .: "tokenUrl"
889+ "accessCode" -> OAuth2AccessCode
890890 <$> o .: "authorizationUrl"
891891 <*> o .: "tokenUrl"
892892 _ -> empty
893893 parseJSON _ = empty
894894
895−instance FromJSON SwaggerOAuth2Params where
896− parseJSON = genericParseJSONWithSub "flow" (jsonPrefix "swaggerOAuth2")
895+instance FromJSON OAuth2Params where
896+ parseJSON = genericParseJSONWithSub "flow" (jsonPrefix "oauth2")
897897
898−instance FromJSON SwaggerSecuritySchemeType where
898+instance FromJSON SecuritySchemeType where
899899 parseJSON json@(Object o) = do
900900 (t :: Text) <- o .: "type"
901901 case t of
902− "basic" -> pure SwaggerSecuritySchemeBasic
903− "apiKey" -> SwaggerSecuritySchemeApiKey <$> parseJSON json
904− "oauth2" -> SwaggerSecuritySchemeOAuth2 <$> parseJSON json
902+ "basic" -> pure SecuritySchemeBasic
903+ "apiKey" -> SecuritySchemeApiKey <$> parseJSON json
904+ "oauth2" -> SecuritySchemeOAuth2 <$> parseJSON json
905905 _ -> empty
906906 parseJSON _ = empty
907907
@@ -909,101 +909,101 @@ instance FromJSON Swagger where
909909 parseJSON json@(Object o) = do
910910 (version :: Text) <- o .: "swagger"
911911 when (version /= "2.0") empty
912− (genericParseJSON (jsonPrefix "swagger")
913− `withDefaults` [ "consumes" .= (mempty :: SwaggerMimeList)
914− , "produces" .= (mempty :: SwaggerMimeList)
915− , "security" .= ([] :: [SwaggerSecurityRequirement])
916− , "tags" .= ([] :: [SwaggerTag])
917− , "definitions" .= (mempty :: HashMap Text SwaggerSchema)
918− , "parameters" .= (mempty :: HashMap Text SwaggerParameter)
919− , "responses" .= (mempty :: HashMap Text SwaggerResponse)
920− , "securityDefinitions" .= (mempty :: HashMap Text SwaggerSecurityScheme)
912+ (genericParseJSON (jsonPrefix "")
913+ `withDefaults` [ "consumes" .= (mempty :: MimeList)
914+ , "produces" .= (mempty :: MimeList)
915+ , "security" .= ([] :: [SecurityRequirement])
916+ , "tags" .= ([] :: [Tag])
917+ , "definitions" .= (mempty :: HashMap Text Schema)
918+ , "parameters" .= (mempty :: HashMap Text Parameter)
919+ , "responses" .= (mempty :: HashMap Text Response)
920+ , "securityDefinitions" .= (mempty :: HashMap Text SecurityScheme)
921921 ] ) json
922922 parseJSON _ = empty
923923
924−instance FromJSON SwaggerSecurityScheme where
925− parseJSON = genericParseJSONWithSub "type" (jsonPrefix "swaggerSecurityScheme")
924+instance FromJSON SecurityScheme where
925+ parseJSON = genericParseJSONWithSub "type" (jsonPrefix "securityScheme")
926926
927−instance FromJSON SwaggerSchema where
928− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerSchema")
929− `withDefaults` [ "properties" .= (mempty :: HashMap Text SwaggerSchema)
930− , "required" .= ([] :: [SwaggerParamName]) ]
927+instance FromJSON Schema where
928+ parseJSON = genericParseJSONWithSub "schemaCommon" (jsonPrefix "schema")
929+ `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
930+ , "required" .= ([] :: [ParamName]) ]
931931
932−instance FromJSON SwaggerHeader where
933− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerHeader")
932+instance FromJSON Header where
933+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "header")
934934
935−instance FromJSON SwaggerItems where
936− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerItems")
935+instance FromJSON Items where
936+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "items")
937937
938−instance FromJSON SwaggerHost where
938+instance FromJSON Host where
939939 parseJSON (String s) =
940940 case fromInteger <$> readMaybe portStr of
941941 Nothing | not (null portStr) -> fail $ "Invalid port `" ++ portStr ++ "'"
942− mport -> pure $ SwaggerHost host mport
942+ mport -> pure $ Host host mport
943943 where
944944 (hostText, portText) = Text.breakOn ":" s
945945 [host, portStr] = map Text.unpack [hostText, portText]
946946 parseJSON _ = empty
947947
948−instance FromJSON SwaggerPaths where
949− parseJSON json = SwaggerPaths <$> parseJSON json
948+instance FromJSON Paths where
949+ parseJSON json = Paths <$> parseJSON json
950950
951−instance FromJSON SwaggerMimeList where
952− parseJSON json = (SwaggerMimeList . map fromString) <$> parseJSON json
951+instance FromJSON MimeList where
952+ parseJSON json = (MimeList . map fromString) <$> parseJSON json
953953
954−instance FromJSON SwaggerParameter where
955− parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "swaggerParameter")
954+instance FromJSON Parameter where
955+ parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "parameter")
956956
957−instance FromJSON SwaggerParameterSchema where
957+instance FromJSON ParameterSchema where
958958 parseJSON json@(Object o) = do
959959 (i :: Text) <- o .: "in"
960960 case i of
961961 "body" -> do
962962 schema <- o .: "schema"
963− SwaggerParameterBody <$> parseJSON schema
964− _ -> SwaggerParameterOther <$> parseJSON json
963+ ParameterBody <$> parseJSON schema
964+ _ -> ParameterOther <$> parseJSON json
965965 parseJSON _ = empty
966966
967−instance FromJSON SwaggerParameterOtherSchema where
968− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "swaggerParameterOtherSchema")
967+instance FromJSON ParameterOtherSchema where
968+ parseJSON = genericParseJSONWithSub "common" (jsonPrefix "parameterOtherSchema")
969969
970−instance FromJSON SwaggerSchemaItems where
971− parseJSON json@(Object _) = SwaggerSchemaItemsObject <$> parseJSON json
972− parseJSON json@(Array _) = SwaggerSchemaItemsArray <$> parseJSON json
970+instance FromJSON SchemaItems where
971+ parseJSON json@(Object _) = SchemaItemsObject <$> parseJSON json
972+ parseJSON json@(Array _) = SchemaItemsArray <$> parseJSON json
973973 parseJSON _ = empty
974974
975−instance FromJSON SwaggerResponses where
976− parseJSON (Object o) = SwaggerResponses
975+instance FromJSON Responses where
976+ parseJSON (Object o) = Responses
977977 <$> o .:? "default"
978978 <*> (parseJSON (Object (HashMap.delete "default" o)) >>= hashMapReadKeys)
979979 parseJSON _ = empty
980980
981−instance FromJSON SwaggerExample where
981+instance FromJSON Example where
982982 parseJSON json = do
983983 m <- parseJSON json
984− pure $ SwaggerExample (Map.mapKeys fromString m)
984+ pure $ Example (Map.mapKeys fromString m)
985985
986−instance FromJSON SwaggerResponse where
987− parseJSON = genericParseJSON (jsonPrefix "swaggerResponse")
988− `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName SwaggerHeader) ]
986+instance FromJSON Response where
987+ parseJSON = genericParseJSON (jsonPrefix "response")
988+ `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName Header) ]
989989
990−instance FromJSON SwaggerOperation where
991− parseJSON = genericParseJSON (jsonPrefix "swaggerOperation")
992− `withDefaults` [ "security" .= ([] :: [SwaggerSecurityRequirement]) ]
990+instance FromJSON Operation where
991+ parseJSON = genericParseJSON (jsonPrefix "operation")
992+ `withDefaults` [ "security" .= ([] :: [SecurityRequirement]) ]
993993
994−instance FromJSON SwaggerPathItem where
995− parseJSON = genericParseJSON (jsonPrefix "swaggerPathItem")
996− `withDefaults` [ "parameters" .= ([] :: [SwaggerParameter]) ]
994+instance FromJSON PathItem where
995+ parseJSON = genericParseJSON (jsonPrefix "pathItem")
996+ `withDefaults` [ "parameters" .= ([] :: [Parameter]) ]
997997
998−instance FromJSON SwaggerReference where
999− parseJSON (Object o) = SwaggerReference <$> o .: "$ref"
998+instance FromJSON Reference where
999+ parseJSON (Object o) = Reference <$> o .: "$ref"
10001000 parseJSON _ = empty
10011001
1002−instance FromJSON a => FromJSON (SwaggerReferenced a) where
1002+instance FromJSON a => FromJSON (Referenced a) where
10031003 parseJSON json
1004− = SwaggerRef <$> parseJSON json
1005− <|> SwaggerInline <$> parseJSON json
1004+ = Ref <$> parseJSON json
1005+ <|> Inline <$> parseJSON json
10061006
1007−instance FromJSON SwaggerXml where
1008− parseJSON = genericParseJSON (jsonPrefix "swaggerXml")
1007+instance FromJSON Xml where
1008+ parseJSON = genericParseJSON (jsonPrefix "xml")
10091009
src/Data/Swagger/Internal/Utils.hs+3−3
@@ -58,17 +58,17 @@ genericToJSONWithSub sub opts x =
5858 Object o ->
5959 let so = HashMap.lookupDefault (error "impossible") sub o
6060 in Object (HashMap.delete sub o) <+> so
61− _ -> error "impossible"
61+ _ -> error "genericToJSONWithSub: subjson is not an object"
6262
6363genericParseJSONWithSub :: (Generic a, GFromJSON (Rep a)) => Text -> Options -> Value -> Parser a
6464genericParseJSONWithSub sub opts (Object o) = genericParseJSON opts json
6565 where
6666 json = Object (HashMap.insert sub (Object o) o)
67−genericParseJSONWithSub _ _ _ = error "impossible"
67+genericParseJSONWithSub _ _ _ = error "genericParseJSONWithSub: given json is not an object"
6868
6969(<+>) :: Value -> Value -> Value
7070Object x <+> Object y = Object (x <> y)
71−_ <+> _ = error "impossible"
71+_ <+> _ = error "<+>: merging non-objects"
7272
7373withDefaults :: (Value -> Parser a) -> [Pair] -> Value -> Parser a
7474withDefaults parser defs json@(Object _) = parser (json <+> object defs)
src/Data/Swagger/Lens.hs+66−66
@@ -15,30 +15,30 @@ import Data.Text (Text)
1515-- =======================================================================
1616
1717makeLenses ''Swagger
18−makeLenses ''SwaggerHost
19−makeLenses ''SwaggerInfo
20−makeLenses ''SwaggerContact
21−makeLenses ''SwaggerLicense
22−makeLenses ''SwaggerPaths
23−makeLenses ''SwaggerPathItem
24−makeLenses ''SwaggerTag
25−makeLenses ''SwaggerOperation
26−makeLenses ''SwaggerParameter
27−makePrisms ''SwaggerParameterSchema
28−makeLenses ''SwaggerParameterOtherSchema
29−makeLenses ''SwaggerItems
30−makeLenses ''SwaggerHeader
31−makeLenses ''SwaggerSchema
32−makePrisms ''SwaggerSchemaItems
33−makeLenses ''SwaggerSchemaCommon
34−makeLenses ''SwaggerXml
35−makeLenses ''SwaggerResponses
36−makeLenses ''SwaggerResponse
37−makeLenses ''SwaggerSecurityScheme
38−makePrisms ''SwaggerSecuritySchemeType
39−makeLenses ''SwaggerApiKeyParams
40−makeLenses ''SwaggerOAuth2Params
41−makeLenses ''SwaggerExternalDocs
18+makeLenses ''Host
19+makeLenses ''Info
20+makeLenses ''Contact
21+makeLenses ''License
22+makeLenses ''Paths
23+makeLenses ''PathItem
24+makeLenses ''Tag
25+makeLenses ''Operation
26+makeLenses ''Parameter
27+makePrisms ''ParameterSchema
28+makeLenses ''ParameterOtherSchema
29+makeLenses ''Items
30+makeLenses ''Header
31+makeLenses ''Schema
32+makePrisms ''SchemaItems
33+makeLenses ''SchemaCommon
34+makeLenses ''Xml
35+makeLenses ''Responses
36+makeLenses ''Response
37+makeLenses ''SecurityScheme
38+makePrisms ''SecuritySchemeType
39+makeLenses ''ApiKeyParams
40+makeLenses ''OAuth2Params
41+makeLenses ''ExternalDocs
4242
4343-- =======================================================================
4444-- Helper classy lenses
@@ -47,61 +47,61 @@ makeLenses ''SwaggerExternalDocs
4747class HasDescription s d | s -> d where
4848 description :: Lens' s d
4949
50−instance HasDescription SwaggerResponse Text where description = swaggerResponseDescription
51−instance HasDescription SwaggerInfo (Maybe Text) where description = swaggerInfoDescription
52−instance HasDescription SwaggerTag (Maybe Text) where description = swaggerTagDescription
53−instance HasDescription SwaggerOperation (Maybe Text) where description = swaggerOperationDescription
54−instance HasDescription SwaggerParameter (Maybe Text) where description = swaggerParameterDescription
55−instance HasDescription SwaggerHeader (Maybe Text) where description = swaggerHeaderDescription
56−instance HasDescription SwaggerSchema (Maybe Text) where description = swaggerSchemaDescription
57−instance HasDescription SwaggerSecurityScheme (Maybe Text) where description = swaggerSecuritySchemeDescription
58−instance HasDescription SwaggerExternalDocs (Maybe Text) where description = swaggerExternalDocsDescription
50+instance HasDescription Response Text where description = responseDescription
51+instance HasDescription Info (Maybe Text) where description = infoDescription
52+instance HasDescription Tag (Maybe Text) where description = tagDescription
53+instance HasDescription Operation (Maybe Text) where description = operationDescription
54+instance HasDescription Parameter (Maybe Text) where description = parameterDescription
55+instance HasDescription Header (Maybe Text) where description = headerDescription
56+instance HasDescription Schema (Maybe Text) where description = schemaDescription
57+instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
58+instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
5959
60−class HasSwaggerSchemaCommon s where
61− schemaCommon :: Lens' s SwaggerSchemaCommon
60+class HasSchemaCommon s where
61+ schemaCommon :: Lens' s SchemaCommon
6262
63−instance HasSwaggerSchemaCommon SwaggerSchema where schemaCommon = swaggerSchemaCommon
64−instance HasSwaggerSchemaCommon SwaggerParameterOtherSchema where schemaCommon = swaggerParameterOtherSchemaCommon
65−instance HasSwaggerSchemaCommon SwaggerItems where schemaCommon = swaggerItemsCommon
66−instance HasSwaggerSchemaCommon SwaggerHeader where schemaCommon = swaggerHeaderCommon
67−instance HasSwaggerSchemaCommon SwaggerSchemaCommon where schemaCommon = id
63+instance HasSchemaCommon Schema where schemaCommon = schemaCommon
64+instance HasSchemaCommon ParameterOtherSchema where schemaCommon = parameterOtherSchemaCommon
65+instance HasSchemaCommon Items where schemaCommon = itemsCommon
66+instance HasSchemaCommon Header where schemaCommon = headerCommon
67+instance HasSchemaCommon SchemaCommon where schemaCommon = id
6868
69−schemaDefault :: HasSwaggerSchemaCommon s => Lens' s (Maybe Value)
70−schemaDefault = schemaCommon.swaggerSchemaDefault
69+schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
70+schemaDefault = schemaCommon.schemaCommonDefault
7171
72−schemaMaximum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
73−schemaMaximum = schemaCommon.swaggerSchemaMaximum
72+schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Integer)
73+schemaMaximum = schemaCommon.schemaCommonMaximum
7474
75−schemaExclusiveMaximum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
76−schemaExclusiveMaximum = schemaCommon.swaggerSchemaExclusiveMaximum
75+schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
76+schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
7777
78−schemaMinimum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
79−schemaMinimum = schemaCommon.swaggerSchemaMinimum
78+schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Integer)
79+schemaMinimum = schemaCommon.schemaCommonMinimum
8080
81−schemaExclusiveMinimum :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
82−schemaExclusiveMinimum = schemaCommon.swaggerSchemaExclusiveMinimum
81+schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
82+schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
8383
84−schemaMaxLength :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
85−schemaMaxLength = schemaCommon.swaggerSchemaMaxLength
84+schemaMaxLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
85+schemaMaxLength = schemaCommon.schemaCommonMaxLength
8686
87−schemaMinLength :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
88−schemaMinLength = schemaCommon.swaggerSchemaMinLength
87+schemaMinLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
88+schemaMinLength = schemaCommon.schemaCommonMinLength
8989
90−schemaPattern :: HasSwaggerSchemaCommon s => Lens' s (Maybe Text)
91−schemaPattern = schemaCommon.swaggerSchemaPattern
90+schemaPattern :: HasSchemaCommon s => Lens' s (Maybe Text)
91+schemaPattern = schemaCommon.schemaCommonPattern
9292
93−schemaMaxItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
94−schemaMaxItems = schemaCommon.swaggerSchemaMaxItems
93+schemaMaxItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
94+schemaMaxItems = schemaCommon.schemaCommonMaxItems
9595
96−schemaMinItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
97−schemaMinItems = schemaCommon.swaggerSchemaMinItems
96+schemaMinItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
97+schemaMinItems = schemaCommon.schemaCommonMinItems
9898
99−schemaUniqueItems :: HasSwaggerSchemaCommon s => Lens' s (Maybe Bool)
100−schemaUniqueItems = schemaCommon.swaggerSchemaUniqueItems
99+schemaUniqueItems :: HasSchemaCommon s => Lens' s (Maybe Bool)
100+schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
101101
102−schemaEnum :: HasSwaggerSchemaCommon s => Lens' s (Maybe [Value])
103−schemaEnum = schemaCommon.swaggerSchemaEnum
102+schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
103+schemaEnum = schemaCommon.schemaCommonEnum
104104
105−schemaMultipleOf :: HasSwaggerSchemaCommon s => Lens' s (Maybe Integer)
106−schemaMultipleOf = schemaCommon.swaggerSchemaMultipleOf
105+schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Integer)
106+schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107107
test/Data/SwaggerSpec.hs+159−159
@@ -68,18 +68,18 @@ main = hspec spec
6868-- Info object
6969-- =======================================================================
7070
71−infoExample :: SwaggerInfo
72−infoExample = SwaggerInfo
73− { _swaggerInfoTitle = "Swagger Sample App"
74− , _swaggerInfoDescription = Just "This is a sample server Petstore server."
75− , _swaggerInfoTermsOfService = Just "http://swagger.io/terms/"
76− , _swaggerInfoContact = Just contactExample
77− , _swaggerInfoLicense = Just licenseExample
78− , _swaggerInfoVersion = "1.0.1" }
71+infoExample :: Info
72+infoExample = Info
73+ { _infoTitle = "Swagger Sample App"
74+ , _infoDescription = Just "This is a sample server Petstore server."
75+ , _infoTermsOfService = Just "http://swagger.io/terms/"
76+ , _infoContact = Just contactExample
77+ , _infoLicense = Just licenseExample
78+ , _infoVersion = "1.0.1" }
7979 where
80− license = SwaggerLicense
81− { _swaggerLicenseName = "Apache 2.0"
82− , _swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
80+ license = License
81+ { _licenseName = "Apache 2.0"
82+ , _licenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
8383
8484infoExampleJSON :: Value
8585infoExampleJSON = [aesonQQ|
@@ -104,11 +104,11 @@ infoExampleJSON = [aesonQQ|
104104-- Contact object
105105-- =======================================================================
106106
107−contactExample :: SwaggerContact
108−contactExample = SwaggerContact
109− { _swaggerContactName = Just "API Support"
110− , _swaggerContactUrl = Just (URL "http://www.swagger.io/support")
111− , _swaggerContactEmail = Just "support@swagger.io" }
107+contactExample :: Contact
108+contactExample = Contact
109+ { _contactName = Just "API Support"
110+ , _contactUrl = Just (URL "http://www.swagger.io/support")
111+ , _contactEmail = Just "support@swagger.io" }
112112
113113contactExampleJSON :: Value
114114contactExampleJSON = [aesonQQ|
@@ -123,10 +123,10 @@ contactExampleJSON = [aesonQQ|
123123-- License object
124124-- =======================================================================
125125
126−licenseExample :: SwaggerLicense
127−licenseExample = SwaggerLicense
128− { _swaggerLicenseName = "Apache 2.0"
129− , _swaggerLicenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
126+licenseExample :: License
127+licenseExample = License
128+ { _licenseName = "Apache 2.0"
129+ , _licenseUrl = Just (URL "http://www.apache.org/licenses/LICENSE-2.0.html") }
130130
131131licenseExampleJSON :: Value
132132licenseExampleJSON = [aesonQQ|
@@ -141,47 +141,47 @@ licenseExampleJSON = [aesonQQ|
141141-- Operation object
142142-- =======================================================================
143143
144−operationExample :: SwaggerOperation
144+operationExample :: Operation
145145operationExample = mempty
146− { _swaggerOperationTags = ["pet"]
147− , _swaggerOperationSummary = Just "Updates a pet in the store with form data"
148− , _swaggerOperationDescription = Just ""
149− , _swaggerOperationOperationId = Just "updatePetWithForm"
150− , _swaggerOperationConsumes = Just (SwaggerMimeList ["application/x-www-form-urlencoded"])
151− , _swaggerOperationProduces = Just (SwaggerMimeList ["application/json", "application/xml"])
152− , _swaggerOperationParameters = params
153− , _swaggerOperationResponses = responses
154− , _swaggerOperationSecurity = security
146+ { _operationTags = ["pet"]
147+ , _operationSummary = Just "Updates a pet in the store with form data"
148+ , _operationDescription = Just ""
149+ , _operationOperationId = Just "updatePetWithForm"
150+ , _operationConsumes = Just (MimeList ["application/x-www-form-urlencoded"])
151+ , _operationProduces = Just (MimeList ["application/json", "application/xml"])
152+ , _operationParameters = params
153+ , _operationResponses = responses
154+ , _operationSecurity = security
155155 }
156156 where
157− security = [SwaggerSecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
157+ security = [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
158158
159159 responses = mempty
160− { _swaggerResponsesResponses =
161− [ (200, SwaggerInline mempty { _swaggerResponseDescription = "Pet updated." })
162− , (405, SwaggerInline mempty { _swaggerResponseDescription = "Invalid input" }) ] }
160+ { _responsesResponses =
161+ [ (200, Inline mempty { _responseDescription = "Pet updated." })
162+ , (405, Inline mempty { _responseDescription = "Invalid input" }) ] }
163163
164− params = map SwaggerInline
165− [ SwaggerParameter
166− { _swaggerParameterName = "petId"
167− , _swaggerParameterDescription = Just "ID of pet that needs to be updated"
168− , _swaggerParameterRequired = Just True
169− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterPath) }
170− , SwaggerParameter
171− { _swaggerParameterName = "name"
172− , _swaggerParameterDescription = Just "Updated name of the pet"
173− , _swaggerParameterRequired = Just False
174− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterFormData) }
175− , SwaggerParameter
176− { _swaggerParameterName = "status"
177− , _swaggerParameterDescription = Just "Updated status of the pet"
178− , _swaggerParameterRequired = Just False
179− , _swaggerParameterSchema = SwaggerParameterOther (stringSchema SwaggerParameterFormData) }
164+ params = map Inline
165+ [ Parameter
166+ { _parameterName = "petId"
167+ , _parameterDescription = Just "ID of pet that needs to be updated"
168+ , _parameterRequired = Just True
169+ , _parameterSchema = ParameterOther (stringSchema ParameterPath) }
170+ , Parameter
171+ { _parameterName = "name"
172+ , _parameterDescription = Just "Updated name of the pet"
173+ , _parameterRequired = Just False
174+ , _parameterSchema = ParameterOther (stringSchema ParameterFormData) }
175+ , Parameter
176+ { _parameterName = "status"
177+ , _parameterDescription = Just "Updated status of the pet"
178+ , _parameterRequired = Just False
179+ , _parameterSchema = ParameterOther (stringSchema ParameterFormData) }
180180 ]
181181
182182 stringSchema i = mempty
183− { _swaggerParameterOtherSchemaIn = i
184− , _swaggerParameterOtherSchemaType = SwaggerParamString
183+ { _parameterOtherSchemaIn = i
184+ , _parameterOtherSchemaType = ParamString
185185 }
186186
187187operationExampleJSON :: Value
@@ -246,10 +246,10 @@ operationExampleJSON = [aesonQQ|
246246-- Schema object
247247-- =======================================================================
248248
249−schemaPrimitiveExample :: SwaggerSchema
249+schemaPrimitiveExample :: Schema
250250schemaPrimitiveExample = mempty
251− { _swaggerSchemaType = SwaggerSchemaString
252− , _swaggerSchemaFormat = Just "email"
251+ { _schemaType = SchemaString
252+ , _schemaFormat = Just "email"
253253 }
254254
255255schemaPrimitiveExampleJSON :: Value
@@ -260,19 +260,19 @@ schemaPrimitiveExampleJSON = [aesonQQ|
260260}
261261|]
262262
263−schemaSimpleModelExample :: SwaggerSchema
263+schemaSimpleModelExample :: Schema
264264schemaSimpleModelExample = mempty
265− { _swaggerSchemaType = SwaggerSchemaObject
266− , _swaggerSchemaRequired = [ "name" ]
267− , _swaggerSchemaProperties =
268− [ ("name", SwaggerInline mempty
269− { _swaggerSchemaType = SwaggerSchemaString } )
270− , ("address", SwaggerRef (SwaggerReference "#/definitions/Address"))
271− , ("age", SwaggerInline mempty
272− { _swaggerSchemaType = SwaggerSchemaInteger
273− , _swaggerSchemaFormat = Just "int32"
274− , _swaggerSchemaCommon = mempty
275− { _swaggerSchemaMinimum = Just 0 } } ) ] }
265+ { _schemaType = SchemaObject
266+ , _schemaRequired = [ "name" ]
267+ , _schemaProperties =
268+ [ ("name", Inline mempty
269+ { _schemaType = SchemaString } )
270+ , ("address", Ref (Reference "#/definitions/Address"))
271+ , ("age", Inline mempty
272+ { _schemaType = SchemaInteger
273+ , _schemaFormat = Just "int32"
274+ , _schemaSchemaCommon = mempty
275+ { _schemaCommonMinimum = Just 0 } } ) ] }
276276
277277schemaSimpleModelExampleJSON :: Value
278278schemaSimpleModelExampleJSON = [aesonQQ|
@@ -297,11 +297,11 @@ schemaSimpleModelExampleJSON = [aesonQQ|
297297}
298298|]
299299
300−schemaModelDictExample :: SwaggerSchema
300+schemaModelDictExample :: Schema
301301schemaModelDictExample = mempty
302− { _swaggerSchemaType = SwaggerSchemaObject
303− , _swaggerSchemaAdditionalProperties = Just mempty
304− { _swaggerSchemaType = SwaggerSchemaString } }
302+ { _schemaType = SchemaObject
303+ , _schemaAdditionalProperties = Just mempty
304+ { _schemaType = SchemaString } }
305305
306306schemaModelDictExampleJSON :: Value
307307schemaModelDictExampleJSON = [aesonQQ|
@@ -313,17 +313,17 @@ schemaModelDictExampleJSON = [aesonQQ|
313313}
314314|]
315315
316−schemaWithExampleExample :: SwaggerSchema
316+schemaWithExampleExample :: Schema
317317schemaWithExampleExample = mempty
318− { _swaggerSchemaType = SwaggerSchemaObject
319− , _swaggerSchemaProperties =
320− [ ("id", SwaggerInline mempty
321− { _swaggerSchemaType = SwaggerSchemaInteger
322− , _swaggerSchemaFormat = Just "int64" })
323− , ("name", SwaggerInline mempty
324− { _swaggerSchemaType = SwaggerSchemaString }) ]
325− , _swaggerSchemaRequired = [ "name" ]
326− , _swaggerSchemaExample = Just [aesonQQ|
318+ { _schemaType = SchemaObject
319+ , _schemaProperties =
320+ [ ("id", Inline mempty
321+ { _schemaType = SchemaInteger
322+ , _schemaFormat = Just "int64" })
323+ , ("name", Inline mempty
324+ { _schemaType = SchemaString }) ]
325+ , _schemaRequired = [ "name" ]
326+ , _schemaExample = Just [aesonQQ|
327327 {
328328 "name": "Puma",
329329 "id": 1
@@ -357,24 +357,24 @@ schemaWithExampleExampleJSON = [aesonQQ|
357357-- Definitions object
358358-- =======================================================================
359359
360−definitionsExample :: HashMap Text SwaggerSchema
360+definitionsExample :: HashMap Text Schema
361361definitionsExample =
362362 [ ("Category", mempty
363− { _swaggerSchemaType = SwaggerSchemaObject
364− , _swaggerSchemaProperties =
365− [ ("id", SwaggerInline mempty
366− { _swaggerSchemaType = SwaggerSchemaInteger
367− , _swaggerSchemaFormat = Just "int64" })
368− , ("name", SwaggerInline mempty
369− { _swaggerSchemaType = SwaggerSchemaString }) ] })
363+ { _schemaType = SchemaObject
364+ , _schemaProperties =
365+ [ ("id", Inline mempty
366+ { _schemaType = SchemaInteger
367+ , _schemaFormat = Just "int64" })
368+ , ("name", Inline mempty
369+ { _schemaType = SchemaString }) ] })
370370 , ("Tag", mempty
371− { _swaggerSchemaType = SwaggerSchemaObject
372− , _swaggerSchemaProperties =
373− [ ("id", SwaggerInline mempty
374− { _swaggerSchemaType = SwaggerSchemaInteger
375− , _swaggerSchemaFormat = Just "int64" })
376− , ("name", SwaggerInline mempty
377− { _swaggerSchemaType = SwaggerSchemaString }) ] }) ]
371+ { _schemaType = SchemaObject
372+ , _schemaProperties =
373+ [ ("id", Inline mempty
374+ { _schemaType = SchemaInteger
375+ , _schemaFormat = Just "int64" })
376+ , ("name", Inline mempty
377+ { _schemaType = SchemaString }) ] }) ]
378378
379379definitionsExampleJSON :: Value
380380definitionsExampleJSON = [aesonQQ|
@@ -410,24 +410,24 @@ definitionsExampleJSON = [aesonQQ|
410410-- Parameters Definition object
411411-- =======================================================================
412412
413−parametersDefinitionExample :: HashMap Text SwaggerParameter
413+parametersDefinitionExample :: HashMap Text Parameter
414414parametersDefinitionExample =
415415 [ ("skipParam", mempty
416− { _swaggerParameterName = "skip"
417− , _swaggerParameterDescription = Just "number of items to skip"
418− , _swaggerParameterRequired = Just True
419− , _swaggerParameterSchema = SwaggerParameterOther mempty
420− { _swaggerParameterOtherSchemaIn = SwaggerParameterQuery
421− , _swaggerParameterOtherSchemaType = SwaggerParamInteger
422− , _swaggerParameterOtherSchemaFormat = Just "int32" } })
416+ { _parameterName = "skip"
417+ , _parameterDescription = Just "number of items to skip"
418+ , _parameterRequired = Just True
419+ , _parameterSchema = ParameterOther mempty
420+ { _parameterOtherSchemaIn = ParameterQuery
421+ , _parameterOtherSchemaType = ParamInteger
422+ , _parameterOtherSchemaFormat = Just "int32" } })
423423 , ("limitParam", mempty
424− { _swaggerParameterName = "limit"
425− , _swaggerParameterDescription = Just "max records to return"
426− , _swaggerParameterRequired = Just True
427− , _swaggerParameterSchema = SwaggerParameterOther mempty
428− { _swaggerParameterOtherSchemaIn = SwaggerParameterQuery
429− , _swaggerParameterOtherSchemaType = SwaggerParamInteger
430− , _swaggerParameterOtherSchemaFormat = Just "int32" } }) ]
424+ { _parameterName = "limit"
425+ , _parameterDescription = Just "max records to return"
426+ , _parameterRequired = Just True
427+ , _parameterSchema = ParameterOther mempty
428+ { _parameterOtherSchemaIn = ParameterQuery
429+ , _parameterOtherSchemaType = ParamInteger
430+ , _parameterOtherSchemaFormat = Just "int32" } }) ]
431431
432432parametersDefinitionExampleJSON :: Value
433433parametersDefinitionExampleJSON = [aesonQQ|
@@ -455,10 +455,10 @@ parametersDefinitionExampleJSON = [aesonQQ|
455455-- Responses Definition object
456456-- =======================================================================
457457
458−responsesDefinitionExample :: HashMap Text SwaggerResponse
458+responsesDefinitionExample :: HashMap Text Response
459459responsesDefinitionExample =
460− [ ("NotFound", mempty { _swaggerResponseDescription = "Entity not found." })
461− , ("IllegalInput", mempty { _swaggerResponseDescription = "Illegal input for operation." }) ]
460+ [ ("NotFound", mempty { _responseDescription = "Entity not found." })
461+ , ("IllegalInput", mempty { _responseDescription = "Illegal input for operation." }) ]
462462
463463responsesDefinitionExampleJSON :: Value
464464responsesDefinitionExampleJSON = [aesonQQ|
@@ -476,18 +476,18 @@ responsesDefinitionExampleJSON = [aesonQQ|
476476-- Responses Definition object
477477-- =======================================================================
478478
479−securityDefinitionsExample :: HashMap Text SwaggerSecurityScheme
479+securityDefinitionsExample :: HashMap Text SecurityScheme
480480securityDefinitionsExample =
481− [ ("api_key", SwaggerSecurityScheme
482− { _swaggerSecuritySchemeType = SwaggerSecuritySchemeApiKey (SwaggerApiKeyParams "api_key" SwaggerApiKeyHeader)
483− , _swaggerSecuritySchemeDescription = Nothing })
484− , ("petstore_auth", SwaggerSecurityScheme
485− { _swaggerSecuritySchemeType = SwaggerSecuritySchemeOAuth2 (SwaggerOAuth2Params
486− { _swaggerOAuth2Flow = SwaggerOAuth2Implicit "http://swagger.io/api/oauth/dialog"
487− , _swaggerOAuth2Scopes =
481+ [ ("api_key", SecurityScheme
482+ { _securitySchemeType = SecuritySchemeApiKey (ApiKeyParams "api_key" ApiKeyHeader)
483+ , _securitySchemeDescription = Nothing })
484+ , ("petstore_auth", SecurityScheme
485+ { _securitySchemeType = SecuritySchemeOAuth2 (OAuth2Params
486+ { _oauth2Flow = OAuth2Implicit "http://swagger.io/api/oauth/dialog"
487+ , _oauth2Scopes =
488488 [ ("write:pets", "modify pets in your account")
489489 , ("read:pets", "read your pets") ] } )
490− , _swaggerSecuritySchemeDescription = Nothing }) ]
490+ , _securitySchemeDescription = Nothing }) ]
491491
492492securityDefinitionsExampleJSON :: Value
493493securityDefinitionsExampleJSON = [aesonQQ|
@@ -515,47 +515,47 @@ securityDefinitionsExampleJSON = [aesonQQ|
515515
516516swaggerExample :: Swagger
517517swaggerExample = mempty
518− { _swaggerBasePath = Just "/"
519− , _swaggerSchemes = Just [Http]
520− , _swaggerInfo = mempty
521− { _swaggerInfoVersion = "1.0"
522− , _swaggerInfoTitle = "Todo API"
523− , _swaggerInfoLicense = Just SwaggerLicense
524− { _swaggerLicenseName = "MIT"
525− , _swaggerLicenseUrl = Just (URL "http://mit.com") }
526− , _swaggerInfoDescription = Just "This is a an API that tests servant-swagger support for a Todo API" }
527− , _swaggerPaths = mempty
528− { _swaggerPathsMap =
518+ { _basePath = Just "/"
519+ , _schemes = Just [Http]
520+ , _info = mempty
521+ { _infoVersion = "1.0"
522+ , _infoTitle = "Todo API"
523+ , _infoLicense = Just License
524+ { _licenseName = "MIT"
525+ , _licenseUrl = Just (URL "http://mit.com") }
526+ , _infoDescription = Just "This is a an API that tests servant-swagger support for a Todo API" }
527+ , _paths = mempty
528+ { _pathsMap =
529529 [ ("/todo/{id}", mempty
530− { _swaggerPathItemGet = Just mempty
531− { _swaggerOperationResponses = mempty
532− { _swaggerResponsesResponses =
533− [ (200, SwaggerInline mempty
534− { _swaggerResponseSchema = Just $ SwaggerInline mempty
535− { _swaggerSchemaExample = Just [aesonQQ|
530+ { _pathItemGet = Just mempty
531+ { _operationResponses = mempty
532+ { _responsesResponses =
533+ [ (200, Inline mempty
534+ { _responseSchema = Just $ Inline mempty
535+ { _schemaExample = Just [aesonQQ|
536536 {
537537 "created": 100,
538538 "description": "get milk"
539539 } |]
540− , _swaggerSchemaType = SwaggerSchemaObject
541− , _swaggerSchemaDescription = Just "This is some real Todo right here"
542− , _swaggerSchemaProperties =
543− [ ("created", SwaggerInline mempty
544− { _swaggerSchemaType = SwaggerSchemaInteger
545− , _swaggerSchemaFormat = Just "int32" })
546− , ("description", SwaggerInline mempty
547− { _swaggerSchemaType = SwaggerSchemaString }) ] }
548− , _swaggerResponseDescription = "OK" }) ] }
549− , _swaggerOperationProduces = Just (SwaggerMimeList [ "application/json" ])
550− , _swaggerOperationParameters =
551− [ SwaggerInline mempty
552− { _swaggerParameterRequired = Just True
553− , _swaggerParameterName = "id"
554− , _swaggerParameterDescription = Just "TodoId param"
555− , _swaggerParameterSchema = SwaggerParameterOther mempty
556− { _swaggerParameterOtherSchemaIn = SwaggerParameterPath
557− , _swaggerParameterOtherSchemaType = SwaggerParamString } } ]
558− , _swaggerOperationTags = [ "todo" ] } }) ] } }
540+ , _schemaType = SchemaObject
541+ , _schemaDescription = Just "This is some real Todo right here"
542+ , _schemaProperties =
543+ [ ("created", Inline mempty
544+ { _schemaType = SchemaInteger
545+ , _schemaFormat = Just "int32" })
546+ , ("description", Inline mempty
547+ { _schemaType = SchemaString }) ] }
548+ , _responseDescription = "OK" }) ] }
549+ , _operationProduces = Just (MimeList [ "application/json" ])
550+ , _operationParameters =
551+ [ Inline mempty
552+ { _parameterRequired = Just True
553+ , _parameterName = "id"
554+ , _parameterDescription = Just "TodoId param"
555+ , _parameterSchema = ParameterOther mempty
556+ { _parameterOtherSchemaIn = ParameterPath
557+ , _parameterOtherSchemaType = ParamString } } ]
558+ , _operationTags = [ "todo" ] } }) ] } }
559559
560560swaggerExampleJSON :: Value
561561swaggerExampleJSON = [aesonQQ|