Search code examples
apiblueprint

How to define the format a string Parameter must take?


We have a querystring parameter called imageDimensions, which specifies the desired dimensions for images of different types. e.g. ?imageDimensions=poster:600x800,badge:100x100

Is there a way in API Blueprint to specify that imageDimensions should be a comma-separated list of image dimension specs, each of form "(image type):(width)x(height)"?


Solution

  • There is no good dedicated syntax for it at the moment. I would probably go with something like:

    ## GET /resource{?imageDimensions}
    + Parameters
        + imageDimensions (string, optional) - Comma-separated list of image dimension specs, each of form `(image type):(width)x(height)`
    
            Where the `(image type)` is one of the following:
    
            - badge
            - poster
            - icon
    
            + Sample: `badge:100x100`
            + Sample: `poster:600x800`
            + Sample: `poster:600x800,badge:100x100`
    
    + Response 200
    

    Note, it is planned to move the parameters syntax to full MSON syntax in the near future. See the API Blueprint roadmap.

    With it, it should be possible to define types for images as an enum and then reference it in the blueprint.