I'm working on a definition/documentation-first specification of an API using Swagger 2.0. I've managed to break-out most reusable components into a definitions section however I am having trouble figuring out how to create reusable definitions for arrays of constants.
For example, I have a few paths that will return images, like this one:
paths:
/resource/{imageId}:
get:
produces:
- image/jpeg
- image/png
- image/gif
parameters:
- in: path
name: imageId
type: string
required: true
responses:
200:
description: Success
schema:
type: file
Which works just fine, but I would like to be able to define a reusable array of the values for the "produces" element so that I can reuse the same list for any path that will produce an image.
The following seemed like the intuitive approach, but swagger reports that the definition for imageMimeTypes is not valid:
paths:
/resource/{imageId}:
get:
produces:
$ref: "#/definitions/imageMimeTypes"
parameters:
- in: path
name: imageId
type: string
required: true
responses:
200:
description: Success
schema:
type: file
definitions:
imageMimeTypes:
- image/jpeg
- image/png
- image/gif
Is it possible to create a definition for an array like this? If so, what syntax should be used?