【问题标题】:How to define the format a string Parameter must take?如何定义字符串参数必须采用的格式?
【发布时间】:2015-11-27 03:39:17
【问题描述】:

我们有一个名为 imageDimensions 的查询字符串参数,它为不同类型的图像指定所需的尺寸。 例如?imageDimensions=poster:600x800,badge:100x100

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

【问题讨论】:

    标签: apiblueprint


    【解决方案1】:

    目前没有很好的专用语法。我可能会选择类似的东西:

    ## 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,然后在蓝图中引用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 2021-05-22
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多