@@ -1,5 +1,6 @@
11module Data.Swagger.Internal where
22
3+import qualified Data.Aeson as JSON
34import Data.HashMap.Strict (HashMap)
45import Data.Text (Text)
56import Network (HostName, PortNumber)
@@ -230,7 +231,129 @@ data SwaggerOperation = SwaggerOperation
230231 , swaggerOperationSecurity :: [SwaggerSecurityRequirement]
231232 } deriving (Show)
232233
234+-- | Describes a single operation parameter.
235+-- A unique parameter is defined by a combination of a name and location.
233236data SwaggerParameter = SwaggerParameter
237+ { -- | The name of the parameter.
238+ -- Parameter names are case sensitive.
239+ swaggerParameterName :: Text
240+
241+ -- | A brief description of the parameter.
242+ -- This could contain examples of use.
243+ -- GFM syntax can be used for rich text representation.
244+ , swaggerParameterDescription :: Maybe Text
245+
246+ -- | Determines whether this parameter is mandatory.
247+ -- If the parameter is in "path", this property is required and its value MUST be true.
248+ -- Otherwise, the property MAY be included and its default value is @False@.
249+ , swaggerParameterRequired :: Bool
250+
251+ -- | Parameter schema.
252+ , swaggerParameterSchema :: SwaggerParameterSchema
253+ } deriving (Show)
254+
255+data SwaggerParameterSchema
256+ = SwaggerParameterBody SwaggerSchema
257+ | SwaggerParameterOther SwaggerParameterOtherSchema
258+ deriving (Show)
259+
260+data SwaggerParameterOtherSchema = SwaggerParameterOtherSchema
261+ { -- | The location of the parameter.
262+ swaggerParameterOtherSchemaIn :: SwaggerParameterLocation
263+
264+ -- | The type of the parameter.
265+ -- Since the parameter is not located at the request body,
266+ -- it is limited to simple types (that is, not an object).
267+ -- If type is @'SwaggerParamFile'@, the @consumes@ MUST be either
268+ -- "multipart/form-data" or " application/x-www-form-urlencoded"
269+ -- and the parameter MUST be in @'SwaggerParameterFormData'@.
270+ , swaggerParameterOtherSchemaType :: SwaggerParameterType
271+
272+ -- | The extending format for the previously mentioned type.
273+ , swaggerParameterOtherSchemaFormat :: Maybe SwaggerFormat
274+
275+ -- | Sets the ability to pass empty-valued parameters.
276+ -- This is valid only for either @'SwaggerParameterQuery'@ or @'SwaggerParameterFormData'@
277+ -- and allows you to send a parameter with a name only or an empty value.
278+ -- Default value is @False@.
279+ , swaggerParameterOtherSchemaAllowEmptyValue :: Bool
280+
281+ -- | __Required if type is @'SwaggerParamArray'@__.
282+ -- Describes the type of items in the array.
283+ , swaggerParameterOtherSchemaItems :: Maybe SwaggerItems
284+
285+ -- | Determines the format of the array if @'SwaggerParamArray'@ is used.
286+ -- Default value is csv.
287+ , swaggerParameterOtherSchemaCollectionFormat :: Maybe SwaggerCollectionFormat
288+
289+ -- | Declares the value of the parameter that the server will use if none is provided,
290+ -- for example a @"count"@ to control the number of results per page might default to @100@
291+ -- if not supplied by the client in the request.
292+ -- (Note: "default" has no meaning for required parameters.)
293+ -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
294+ , swaggerParameterOtherSchemaDefault :: Maybe JSON.Value
295+
296+ , swaggerParameterOtherSchemaMaximum :: Maybe Integer
297+ , swaggerParameterOtherSchemaExclusiveMaximum :: Maybe Bool
298+ , swaggerParameterOtherSchemaMinimum :: Maybe Integer
299+ , swaggerParameterOtherSchemaExclusiveMinimum :: Maybe Bool
300+ , swaggerParameterOtherSchemaMaxLength :: Maybe Integer
301+ , swaggerParameterOtherSchemaMinLength :: Maybe Integer
302+ , swaggerParameterOtherSchemaPattern :: Maybe Text
303+ , swaggerParameterOtherSchemaMaxItems :: Maybe Integer
304+ , swaggerParameterOtherSchemaMinItems :: Maybe Integer
305+ , swaggerParameterOtherSchemaUniqueItems :: Maybe Bool
306+ , swaggerParameterOtherSchemaEnum :: Maybe [JSON.Value]
307+ , swaggerParameterOtherSchemaMultipleOf :: Maybe Integer
308+ } deriving (Show)
309+
310+data SwaggerParameterType
311+ = SwaggerParamString
312+ | SwaggerParamNumber
313+ | SwaggerParamInteger
314+ | SwaggerParamBoolean
315+ | SwaggerParamArray
316+ | SwaggerParamFile
317+ deriving (Show)
318+
319+data SwaggerParameterLocation
320+ = -- | Parameters that are appended to the URL.
321+ -- For example, in @/items?id=###@, the query parameter is @id@.
322+ SwaggerParameterQuery
323+ -- | Custom headers that are expected as part of the request.
324+ | SwaggerParameterHeader
325+ -- | Used together with Path Templating, where the parameter value is actually part of the operation's URL.
326+ -- This does not include the host or base path of the API.
327+ -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
328+ | SwaggerParameterPath
329+ -- | Used to describe the payload of an HTTP request when either @application/x-www-form-urlencoded@
330+ -- or @multipart/form-data@ are used as the content type of the request
331+ -- (in Swagger's definition, the @consumes@ property of an operation).
332+ -- This is the only parameter type that can be used to send files, thus supporting the @'SwaggerParamFile'@ type.
333+ -- Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
334+ -- Form parameters have a different format based on the content-type used
335+ -- (for further details, consult <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>).
336+ | SwaggerParameterFormData
337+ deriving (Show)
338+
339+type SwaggerFormat = Text
340+
341+-- | Determines the format of the array.
342+data SwaggerCollectionFormat
343+ = SwaggerCollectionCSV -- ^ Comma separated values: @foo,bar@.
344+ | SwaggerCollectionSSV -- ^ Space separated values @foo bar@.
345+ | SwaggerCollectionTSV -- ^ Tab separated values @foo\\tbar@.
346+ | SwaggerCollectionPipes -- ^ Pipe separated values @foo|bar@.
347+ -- | Corresponds to multiple parameter instances
348+ -- instead of multiple values for a single instance @foo=bar&foo=baz@.
349+ -- This is valid only for parameters in @'SwaggerParameterQuery'@ or @'SwaggerParameterFormData'@.
350+ | SwaggerCollectionMulti
351+ deriving (Show)
352+
353+data SwaggerSchema = SwaggerSchema
354+ deriving (Show)
355+
356+data SwaggerItems = SwaggerItems
234357 deriving (Show)
235358
236359data SwaggerResponses = SwaggerResponses