swagger2-1.2.1: Swagger 2.0 data model

Safe HaskellNone
LanguageHaskell2010

Data.Swagger.Internal

Synopsis

Documentation

data Swagger Source

This is the root document object for the API specification.

Constructors

Swagger 

Fields

_info :: Info

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

_host :: Maybe Host

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).

_basePath :: 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 (/).

_schemes :: Maybe [Scheme]

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.

_consumes :: MimeList

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

_produces :: MimeList

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

_paths :: Paths

The available paths and operations for the API.

_definitions :: HashMap Text Schema

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

_parameters :: HashMap Text Param

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

_responses :: HashMap Text Response

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

_securityDefinitions :: HashMap Text SecurityScheme

Security scheme definitions that can be used across the specification.

_security :: [SecurityRequirement]

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.

_tags :: [Tag]

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.

_externalDocs :: Maybe ExternalDocs

Additional external documentation.

data Info 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

Info 

Fields

_infoTitle :: Text

The title of the application.

_infoDescription :: Maybe Text

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

_infoTermsOfService :: Maybe Text

The Terms of Service for the API.

_infoContact :: Maybe Contact

The contact information for the exposed API.

_infoLicense :: Maybe License

The license information for the exposed API.

_infoVersion :: Text

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

data Contact Source

Contact information for the exposed API.

Constructors

Contact 

Fields

_contactName :: Maybe Text

The identifying name of the contact person/organization.

_contactUrl :: Maybe URL

The URL pointing to the contact information.

_contactEmail :: Maybe Text

The email address of the contact person/organization.

data License Source

License information for the exposed API.

Constructors

License 

Fields

_licenseName :: Text

The license name used for the API.

_licenseUrl :: Maybe URL

A URL to the license used for the API.

data Host Source

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

Constructors

Host 

Fields

_hostName :: HostName

Host name.

_hostPort :: Maybe PortNumber

Optional port.

data Scheme Source

The transfer protocol of the API.

Constructors

Http 
Https 
Ws 
Wss 

data Paths Source

The available paths and operations for the API.

Constructors

Paths 

Fields

_pathsMap :: HashMap FilePath PathItem

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

data PathItem Source

Describes the operations available on a single path. A PathItem 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

PathItem 

Fields

_pathItemGet :: Maybe Operation

A definition of a GET operation on this path.

_pathItemPut :: Maybe Operation

A definition of a PUT operation on this path.

_pathItemPost :: Maybe Operation

A definition of a POST operation on this path.

_pathItemDelete :: Maybe Operation

A definition of a DELETE operation on this path.

_pathItemOptions :: Maybe Operation

A definition of a OPTIONS operation on this path.

_pathItemHead :: Maybe Operation

A definition of a HEAD operation on this path.

_pathItemPatch :: Maybe Operation

A definition of a PATCH operation on this path.

_pathItemParameters :: [Referenced Param]

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.

data Operation Source

Describes a single API operation on a path.

Constructors

Operation 

Fields

_operationTags :: [TagName]

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

_operationSummary :: 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.

_operationDescription :: Maybe Text

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

_operationExternalDocs :: Maybe ExternalDocs

Additional external documentation for this operation.

_operationOperationId :: 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.

_operationConsumes :: Maybe MimeList

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

_operationProduces :: Maybe MimeList

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

_operationParameters :: [Referenced Param]

A list of parameters that are applicable for this operation. If a parameter is already defined at the PathItem, 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.

_operationResponses :: Responses

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

_operationSchemes :: Maybe [Scheme]

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

_operationDeprecated :: Maybe Bool

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

_operationSecurity :: [SecurityRequirement]

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.

data Param Source

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

Constructors

Param 

Fields

_paramName :: Text

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

_paramDescription :: Maybe Text

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

_paramRequired :: Maybe 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.

_paramSchema :: ParamAnySchema

Parameter schema.

data SwaggerItems t where Source

Items for SwaggerArray schemas.

SwaggerItemsPrimitive should be used only for query params, headers and path pieces. The CollectionFormat t parameter specifies how elements of an array should be displayed. Note that fmt in SwaggerItemsPrimitive fmt schema specifies format for elements of type schema. This is different from the original Swagger's Items Object.

SwaggerItemsObject should be used to specify homogenous array Schemas.

SwaggerItemsArray should be used to specify tuple Schemas.

data ParamLocation Source

Constructors

ParamQuery

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

ParamHeader

Custom headers that are expected as part of the request.

ParamPath

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.

ParamFormData

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 ParamFile 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 ParamSchema t Source

Constructors

ParamSchema 

Fields

_paramSchemaDefault :: 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.

_paramSchemaType :: SwaggerType t
 
_paramSchemaFormat :: Maybe Format
 
_paramSchemaItems :: Maybe (SwaggerItems t)
 
_paramSchemaMaximum :: Maybe Scientific
 
_paramSchemaExclusiveMaximum :: Maybe Bool
 
_paramSchemaMinimum :: Maybe Scientific
 
_paramSchemaExclusiveMinimum :: Maybe Bool
 
_paramSchemaMaxLength :: Maybe Integer
 
_paramSchemaMinLength :: Maybe Integer
 
_paramSchemaPattern :: Maybe Text
 
_paramSchemaMaxItems :: Maybe Integer
 
_paramSchemaMinItems :: Maybe Integer
 
_paramSchemaUniqueItems :: Maybe Bool
 
_paramSchemaEnum :: Maybe [Value]
 
_paramSchemaMultipleOf :: Maybe Scientific
 

data Xml Source

Constructors

Xml 

Fields

_xmlName :: 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.

_xmlNamespace :: Maybe Text

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

_xmlPrefix :: Maybe Text

The prefix to be used for the name.

_xmlAttribute :: Maybe Bool

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

_xmlWrapped :: Maybe 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).

data Responses 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

Responses 

Fields

_responsesDefault :: Maybe (Referenced Response)

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

_responsesResponses :: HashMap HttpStatusCode (Referenced Response)

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 Response Source

Describes a single response from an API Operation.

Constructors

Response 

Fields

_responseDescription :: Text

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

_responseSchema :: Maybe (Referenced Schema)

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.

_responseHeaders :: HashMap HeaderName Header

A list of headers that are sent with the response.

_responseExamples :: Maybe Example

An example of the response message.

data ApiKeyParams Source

Constructors

ApiKeyParams 

Fields

_apiKeyName :: Text

The name of the header or query parameter to be used.

_apiKeyIn :: ApiKeyLocation

The location of the API key.

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.

data OAuth2Params Source

Constructors

OAuth2Params 

Fields

_oauth2Flow :: OAuth2Flow

The flow used by the OAuth2 security scheme.

_oauth2Scopes :: HashMap Text Text

The available scopes for the OAuth2 security scheme.

newtype SecurityRequirement 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).

type TagName = Text Source

Tag name.

data Tag Source

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

Constructors

Tag 

Fields

_tagName :: TagName

The name of the tag.

_tagDescription :: Maybe Text

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

_tagExternalDocs :: Maybe ExternalDocs

Additional external documentation for this tag.

data ExternalDocs Source

Allows referencing an external resource for extended documentation.

Constructors

ExternalDocs 

Fields

_externalDocsDescription :: Maybe Text

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

_externalDocsUrl :: URL

The URL for the target documentation.

newtype Reference Source

A simple object to allow referencing other definitions in the specification. It can be used to reference parameters and responses that are defined at the top level for reuse.

Constructors

Reference 

Fields

getReference :: Text