swagger2-0.1: Swagger 2.0 data model

Safe HaskellNone
LanguageHaskell2010

Data.Swagger

Contents

Description

Swagger™ is a project used to describe and document RESTful APIs.

The Swagger specification defines a set of files required to describe such an API. These files can then be used by the Swagger-UI project to display the API and Swagger-Codegen to generate clients in various languages. Additional utilities can also take advantage of the resulting files, such as testing tools.

Synopsis

Swagger specification

data Swagger Source

This is the root document object for the API specification.

Constructors

Swagger 

Fields

swaggerInfo :: SwaggerInfo

Provides metadata about the API. The metadata can be used by the clients if needed.

swaggerHost :: Maybe SwaggerHost

The host (name or ip) serving the API. It MAY include a port. If the host is not included, the host serving the documentation is to be used (including the port).

swaggerBasePath :: Maybe FilePath

The base path on which the API is served, which is relative to the host. If it is not included, the API is served directly under the host. The value MUST start with a leading slash (/).

swaggerSchemes :: Maybe [SwaggerScheme]

The transfer protocol of the API. If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.

swaggerConsumes :: SwaggerMimeList

A list of MIME types the APIs can consume. This is global to all APIs but can be overridden on specific API calls.

swaggerProduces :: SwaggerMimeList

A list of MIME types the APIs can produce. This is global to all APIs but can be overridden on specific API calls.

swaggerPaths :: SwaggerPaths

The available paths and operations for the API.

swaggerDefinitions :: HashMap Text SwaggerSchema

An object to hold data types produced and consumed by operations.

swaggerParameters :: HashMap Text SwaggerParameter

An object to hold parameters that can be used across operations. This property does not define global parameters for all operations.

swaggerResponses :: HashMap Text SwaggerResponse

An object to hold responses that can be used across operations. This property does not define global responses for all operations.

swaggerSecurityDefinitions :: HashMap Text SwaggerSecurityScheme

Security scheme definitions that can be used across the specification.

swaggerSecurity :: [SwaggerSecurityRequirement]

A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition.

swaggerTags :: [SwaggerTag]

A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.

swaggerExternalDocs :: Maybe SwaggerExternalDocs

Additional external documentation.

data SwaggerHost Source

The host (name or ip) serving the API. It MAY include a port.

Constructors

SwaggerHost 

Fields

swaggerHostName :: HostName

Host name.

swaggerHostPort :: Maybe PortNumber

Optional port.

Info types

data SwaggerInfo Source

The object provides metadata about the API. The metadata can be used by the clients if needed, and can be presented in the Swagger-UI for convenience.

Constructors

SwaggerInfo 

Fields

swaggerInfoTitle :: Text

The title of the application.

swaggerInfoDescription :: Maybe Text

A short description of the application. GFM syntax can be used for rich text representation.

swaggerInfoTermsOfService :: Maybe Text

The Terms of Service for the API.

swaggerInfoContact :: Maybe SwaggerContact

The contact information for the exposed API.

swaggerInfoLicense :: Maybe SwaggerLicense

The license information for the exposed API.

swaggerInfoVersion :: Text

Provides the version of the application API (not to be confused with the specification version).

data SwaggerContact Source

Contact information for the exposed API.

Constructors

SwaggerContact 

Fields

swaggerContactName :: Maybe Text

The identifying name of the contact person/organization.

swaggerContactUrl :: Maybe URL

The URL pointing to the contact information.

swaggerContactEmail :: Maybe Text

The email address of the contact person/organization.

data SwaggerLicense Source

License information for the exposed API.

Constructors

SwaggerLicense 

Fields

swaggerLicenseName :: Text

The license name used for the API.

swaggerLicenseUrl :: Maybe URL

A URL to the license used for the API.

Paths

data SwaggerPaths Source

The available paths and operations for the API.

Constructors

SwaggerPaths 

Fields

swaggerPathsMap :: HashMap FilePath SwaggerPathItem

Holds the relative paths to the individual endpoints. The path is appended to the swaggerBasePath in order to construct the full URL.

data SwaggerPathItem Source

Describes the operations available on a single path. A SwaggerPathItem may be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.

Constructors

SwaggerPathItem 

Fields

swaggerPathItemGet :: Maybe SwaggerOperation

A definition of a GET operation on this path.

swaggerPathItemPut :: Maybe SwaggerOperation

A definition of a PUT operation on this path.

swaggerPathItemPost :: Maybe SwaggerOperation

A definition of a POST operation on this path.

swaggerPathItemDelete :: Maybe SwaggerOperation

A definition of a DELETE operation on this path.

swaggerPathItemOptions :: Maybe SwaggerOperation

A definition of a OPTIONS operation on this path.

swaggerPathItemHead :: Maybe SwaggerOperation

A definition of a HEAD operation on this path.

swaggerPathItemPatch :: Maybe SwaggerOperation

A definition of a PATCH operation on this path.

swaggerPathItemParameters :: [SwaggerParameter]

A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location.

Operations

data SwaggerTag Source

Allows adding meta data to a single tag that is used by SwaggerOperation. It is not mandatory to have a SwaggerTag per tag used there.

Constructors

SwaggerTag 

Fields

swaggerTagName :: Text

The name of the tag.

swaggerTagDescription :: Maybe Text

A short description for the tag. GFM syntax can be used for rich text representation.

swaggerTagExternalDocs :: Maybe SwaggerExternalDocs

Additional external documentation for this tag.

data SwaggerOperation Source

Describes a single API operation on a path.

Constructors

SwaggerOperation 

Fields

swaggerOperationTags :: [Text]

A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.

swaggerOperationSummary :: Maybe Text

A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.

swaggerOperationDescription :: Maybe Text

A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.

swaggerOperationExternalDocs :: Maybe SwaggerExternalDocs

Additional external documentation for this operation.

swaggerOperationOperationId :: Maybe Text

Unique string used to identify the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the it to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.

swaggerOperationConsumes :: Maybe SwaggerMimeList

A list of MIME types the operation can consume. This overrides the swaggerConsumes. Just [] MAY be used to clear the global definition.

swaggerOperationProduces :: Maybe SwaggerMimeList

A list of MIME types the operation can produce. This overrides the swaggerProduces. Just [] MAY be used to clear the global definition.

swaggerOperationParameters :: [SwaggerParameter]

A list of parameters that are applicable for this operation. If a parameter is already defined at the SwaggerPathItem, the new definition will override it, but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location.

swaggerOperationResponses :: SwaggerResponses

The list of possible responses as they are returned from executing this operation.

swaggerOperationSchemes :: Maybe [SwaggerScheme]

The transfer protocol for the operation. The value overrides swaggerSchemes.

swaggerOperationDeprecated :: Bool

Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is False.

swaggerOperationSecurity :: [SwaggerSecurityRequirement]

A declaration of which security schemes are applied for this operation. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). This definition overrides any declared top-level security. To remove a top-level security declaration, Just [] can be used.

Types and formats

data SwaggerCollectionFormat Source

Determines the format of the array.

Constructors

SwaggerCollectionCSV

Comma separated values: foo,bar.

SwaggerCollectionSSV

Space separated values: foo bar.

SwaggerCollectionTSV

Tab separated values: foo\tbar.

SwaggerCollectionPipes

Pipe separated values: foo|bar.

SwaggerCollectionMulti

Corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in SwaggerParameterQuery or SwaggerParameterFormData.

data SwaggerItemsCollectionFormat Source

Determines the format of the nested array.

Constructors

SwaggerItemsCollectionCSV

Comma separated values: foo,bar.

SwaggerItemsCollectionSSV

Space separated values: foo bar.

SwaggerItemsCollectionTSV

Tab separated values: foo\tbar.

SwaggerItemsCollectionPipes

Pipe separated values: foo|bar.

Parameters

data SwaggerParameter Source

Describes a single operation parameter. A unique parameter is defined by a combination of a name and location.

Constructors

SwaggerParameter 

Fields

swaggerParameterName :: Text

The name of the parameter. Parameter names are case sensitive.

swaggerParameterDescription :: Maybe Text

A brief description of the parameter. This could contain examples of use. GFM syntax can be used for rich text representation.

swaggerParameterRequired :: Bool

Determines whether this parameter is mandatory. If the parameter is in "path", this property is required and its value MUST be true. Otherwise, the property MAY be included and its default value is False.

swaggerParameterSchema :: SwaggerParameterSchema

Parameter schema.

data SwaggerParameterOtherSchema Source

Constructors

SwaggerParameterOtherSchema 

Fields

swaggerParameterOtherSchemaIn :: SwaggerParameterLocation

The location of the parameter.

swaggerParameterOtherSchemaType :: SwaggerParameterType

The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). If type is SwaggerParamFile, the consumes MUST be either "multipartform-data" or " applicationx-www-form-urlencoded" and the parameter MUST be in SwaggerParameterFormData.

swaggerParameterOtherSchemaFormat :: Maybe SwaggerFormat

The extending format for the previously mentioned type.

swaggerParameterOtherSchemaAllowEmptyValue :: Bool

Sets the ability to pass empty-valued parameters. This is valid only for either SwaggerParameterQuery or SwaggerParameterFormData and allows you to send a parameter with a name only or an empty value. Default value is False.

swaggerParameterOtherSchemaItems :: Maybe SwaggerItems

Required if type is SwaggerParamArray. Describes the type of items in the array.

swaggerParameterOtherSchemaCollectionFormat :: Maybe SwaggerCollectionFormat

Determines the format of the array if SwaggerParamArray is used. Default value is csv.

swaggerParameterOtherSchemaCommon :: SwaggerSchemaCommon
 

data SwaggerParameterLocation Source

Constructors

SwaggerParameterQuery

Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.

SwaggerParameterHeader

Custom headers that are expected as part of the request.

SwaggerParameterPath

Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in items{itemId}, the path parameter is itemId.

SwaggerParameterFormData

Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded or multipart/form-data are used as the content type of the request (in Swagger's definition, the consumes property of an operation). This is the only parameter type that can be used to send files, thus supporting the SwaggerParamFile type. Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation. Form parameters have a different format based on the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4).

data SwaggerItems Source

Constructors

SwaggerItems 

Fields

swaggerItemsType :: SwaggerItemsType

The internal type of the array.

swaggerItemsFormat :: SwaggerFormat

The extending format for the previously mentioned type.

swaggerItemsItems :: SwaggerItems

Required if type is SwaggerItemsArray. Describes the type of items in the array.

swaggerItemsCollectionFormat :: SwaggerItemsCollectionFormat

Determines the format of the array if type array is used. Default value is SwaggerItemsCollectionCSV.

swaggerItemsCommon :: SwaggerSchemaCommon
 

data SwaggerHeader Source

Constructors

SwaggerHeader 

Fields

swaggerHeaderDescription :: Maybe String

A short description of the header.

swaggerHeaderType :: SwaggerItemsType

The type of the object.

swaggerHeaderFormat :: Maybe SwaggerFormat

The extending format for the previously mentioned type. See Data Type Formats for further details.

swaggerHeaderItems :: SwaggerItems

Required if type is SwaggerItemsArray. Describes the type of items in the array.

swaggerHeaderCollectionFormat :: SwaggerItemsCollectionFormat

Determines the format of the array if type array is used. Default value is SwaggerItemsCollectionCSV.

swaggerHeaderCommon :: SwaggerSchemaCommon
 

Schema

data SwaggerSchemaCommon Source

Constructors

SwaggerSchemaCommon 

Fields

swaggerSchemaDefault :: Maybe Value

Declares the value of the parameter that the server will use if none is provided, for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request. (Note: "default" has no meaning for required parameters.) Unlike JSON Schema this value MUST conform to the defined type for this parameter.

swaggerSchemaMaximum :: Maybe Integer
 
swaggerSchemaExclusiveMaximum :: Maybe Bool
 
swaggerSchemaMinimum :: Maybe Integer
 
swaggerSchemaExclusiveMinimum :: Maybe Bool
 
swaggerSchemaMaxLength :: Maybe Integer
 
swaggerSchemaMinLength :: Maybe Integer
 
swaggerSchemaPattern :: Maybe Text
 
swaggerSchemaMaxItems :: Maybe Integer
 
swaggerSchemaMinItems :: Maybe Integer
 
swaggerSchemaUniqueItems :: Maybe Bool
 
swaggerSchemaEnum :: Maybe [Value]
 
swaggerSchemaMultipleOf :: Maybe Integer
 

data SwaggerXml Source

Constructors

SwaggerXml 

Fields

swaggerXmlName :: Maybe Text

Replaces the name of the element/attribute used for the described schema property. When defined within the SwaggerItems (items), it will affect the name of the individual XML elements within the list. When defined alongside type being array (outside the items), it will affect the wrapping element and only if wrapped is true. If wrapped is false, it will be ignored.

swaggerXmlNamespace :: Maybe Text

The URL of the namespace definition. Value SHOULD be in the form of a URL.

swaggerXmlPrefix :: Maybe Text

The prefix to be used for the name.

swaggerXmlAttribute :: Bool

Declares whether the property definition translates to an attribute instead of an element. Default value is False.

swaggerXmlWrapped :: Bool

MAY be used only for an array definition. Signifies whether the array is wrapped (for example, <books><book><book></books>) or unwrapped (<book><book>). Default value is False. The definition takes effect only when defined alongside type being array (outside the items).

Responses

data SwaggerResponses Source

A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. It is not expected from the documentation to necessarily cover all possible HTTP response codes, since they may not be known in advance. However, it is expected from the documentation to cover a successful operation response and any known errors.

Constructors

SwaggerResponses 

Fields

swaggerResponsesDefault :: Maybe SwaggerResponse

The documentation of responses other than the ones declared for specific HTTP response codes. It can be used to cover undeclared responses.

swaggerResponsesResponses :: HashMap HttpStatusCode SwaggerResponse

Any HTTP status code can be used as the property name (one property per HTTP status code). Describes the expected response for those HTTP status codes.

data SwaggerResponse Source

Describes a single response from an API Operation.

Constructors

SwaggerResponse 

Fields

swaggerResponseDescription :: Text

A short description of the response. GFM syntax can be used for rich text representation.

swaggerResponseSchema :: Maybe SwaggerSchema

A definition of the response structure. It can be a primitive, an array or an object. If this field does not exist, it means no content is returned as part of the response. As an extension to the Schema Object, its root type value may also be "file". This SHOULD be accompanied by a relevant produces mime-type.

swaggerResponseHeaders :: HashMap HeaderName SwaggerHeader

A list of headers that are sent with the response.

swaggerResponseExamples :: Maybe SwaggerExample

An example of the response message.

Security

newtype SwaggerSecurityRequirement Source

Lists the required security schemes to execute this operation. The object can have multiple security schemes declared in it which are all required (that is, there is a logical AND between the schemes).

API key

OAuth2

type AuthorizationURL = Text Source

The authorization URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.

type TokenURL = Text Source

The token URL to be used for OAuth2 flow. This SHOULD be in the form of a URL.

External documentation

data SwaggerExternalDocs Source

Allows referencing an external resource for extended documentation.

Constructors

SwaggerExternalDocs 

Fields

swaggerExternalDocsDescription :: Maybe Text

A short description of the target documentation. GFM syntax can be used for rich text representation.

swaggerExternalDocsUrl :: URL

The URL for the target documentation.

Miscellaneous