@@ -1,9 +1,10 @@
11module Data.Swagger.Internal where
22
3−import Data.Text (Text)
4−import Network (HostName, PortNumber)
5−import Network.HTTP.Media (MediaType)
6−import Network.URL (URL)
3+import Data.HashMap.Strict (HashMap)
4+import Data.Text (Text)
5+import Network (HostName, PortNumber)
6+import Network.HTTP.Media (MediaType)
7+import Network.URL (URL)
78
89-- | This is the root document object for the API specification.
910data Swagger = Swagger
@@ -130,13 +131,109 @@ data SwaggerScheme
130131data SwaggerPaths = SwaggerPaths
131132 { -- | Holds the relative paths to the individual endpoints.
132133 -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
133− swaggerPathsMap :: [SwaggerPath]
134+ swaggerPathsMap :: HashMap FilePath SwaggerPathItem
134135
135136 -- | Allows extensions to the Swagger Schema.
136137 , swaggerPathsExtensions :: [SwaggerExtension]
137138 } deriving (Show)
138139
139−data SwaggerPath = SwaggerPath
140+-- | Describes the operations available on a single path.
141+-- A @'SwaggerPathItem'@ may be empty, due to ACL constraints.
142+-- The path itself is still exposed to the documentation viewer
143+-- but they will not know which operations and parameters are available.
144+data SwaggerPathItem = SwaggerPathItem
145+ { -- | A definition of a GET operation on this path.
146+ swaggerPathItemGet :: Maybe SwaggerOperation
147+
148+ -- | A definition of a PUT operation on this path.
149+ , swaggerPathItemPut :: Maybe SwaggerOperation
150+
151+ -- | A definition of a POST operation on this path.
152+ , swaggerPathItemPost :: Maybe SwaggerOperation
153+
154+ -- | A definition of a DELETE operation on this path.
155+ , swaggerPathItemDelete :: Maybe SwaggerOperation
156+
157+ -- | A definition of a OPTIONS operation on this path.
158+ , swaggerPathItemOptions :: Maybe SwaggerOperation
159+
160+ -- | A definition of a HEAD operation on this path.
161+ , swaggerPathItemHead :: Maybe SwaggerOperation
162+
163+ -- | A definition of a PATCH operation on this path.
164+ , swaggerPathItemPatch :: Maybe SwaggerOperation
165+
166+ -- | A list of parameters that are applicable for all the operations described under this path.
167+ -- These parameters can be overridden at the operation level, but cannot be removed there.
168+ -- The list MUST NOT include duplicated parameters.
169+ -- A unique parameter is defined by a combination of a name and location.
170+ , swaggerPathItemParameters :: [SwaggerParameter]
171+ } deriving (Show)
172+
173+-- | Describes a single API operation on a path.
174+data SwaggerOperation = SwaggerOperation
175+ { -- | A list of tags for API documentation control.
176+ -- Tags can be used for logical grouping of operations by resources or any other qualifier.
177+ swaggerOperationTags :: [Text]
178+
179+ -- | A short summary of what the operation does.
180+ -- For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
181+ , swaggerOperationSummary :: Maybe Text
182+
183+ -- | A verbose explanation of the operation behavior.
184+ -- GFM syntax can be used for rich text representation.
185+ , swaggerOperationDescription :: Maybe Text
186+
187+ -- | Additional external documentation for this operation.
188+ , swaggerOperationExternalDocs :: Maybe SwaggerExternalDocs
189+
190+ -- | Unique string used to identify the operation.
191+ -- The id MUST be unique among all operations described in the API.
192+ -- Tools and libraries MAY use the it to uniquely identify an operation,
193+ -- therefore, it is recommended to follow common programming naming conventions.
194+ , swaggerOperationOperationId :: Maybe Text
195+
196+ -- | A list of MIME types the operation can consume.
197+ -- This overrides the @'swaggerConsumes'@.
198+ -- @Just []@ MAY be used to clear the global definition.
199+ , swaggerOperationConsumes :: Maybe [MediaType]
200+
201+ -- | A list of MIME types the operation can produce.
202+ -- This overrides the @'swaggerProduces'@.
203+ -- @Just []@ MAY be used to clear the global definition.
204+ , swaggerOperationProduces :: Maybe [MediaType]
205+
206+ -- | A list of parameters that are applicable for this operation.
207+ -- If a parameter is already defined at the @'SwaggerPathItem'@,
208+ -- the new definition will override it, but can never remove it.
209+ -- The list MUST NOT include duplicated parameters.
210+ -- A unique parameter is defined by a combination of a name and location.
211+ , swaggerOperationParameters :: [SwaggerParameter]
212+
213+ -- | The list of possible responses as they are returned from executing this operation.
214+ , swaggerOperationResponses :: SwaggerResponses
215+
216+ -- | The transfer protocol for the operation.
217+ -- The value overrides @'swaggerSchemes'@.
218+ , swaggerOperationSchemes :: Maybe [SwaggerScheme]
219+
220+ -- | Declares this operation to be deprecated.
221+ -- Usage of the declared operation should be refrained.
222+ -- Default value is @False@.
223+ , swaggerOperationDeprecated :: Bool
224+
225+ -- | A declaration of which security schemes are applied for this operation.
226+ -- The list of values describes alternative security schemes that can be used
227+ -- (that is, there is a logical OR between the security requirements).
228+ -- This definition overrides any declared top-level security.
229+ -- To remove a top-level security declaration, @Just []@ can be used.
230+ , swaggerOperationSecurity :: [SwaggerSecurityRequirement]
231+ } deriving (Show)
232+
233+data SwaggerParameter = SwaggerParameter
234+ deriving (Show)
235+
236+data SwaggerResponses = SwaggerResponses
140237 deriving (Show)
141238
142239data SwaggerExtension = SwaggerExtension