2015-11-27 28 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,然後在藍圖中引用它。

相關問題