2015-11-27 25 views
0

我们有一个名为imageDimensions的querystring参数,它指定了不同类型图像的所需尺寸。 例如?imageDimensions=poster:600x800,badge:100x100如何定义字符串参数必须采用的格式?

在API蓝图中是否有方法指定imageDimensions应该是逗号分隔的图像尺寸规格列表,每种格式为“(图像类型):(宽度)x(高度)”?

回答

5

目前没有好的专用语法。我可能会喜欢的东西去:

## 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 

注意,计划到参数语法移动到全MSON syntax在不久的将来。请参阅API Blueprint roadmap

有了它,应该可以将图像的类型定义为enum,然后在蓝图中引用它。

相关问题