如何在 raml 查询参数中定义 map[string][]string

how to define map[string][]string in raml query parameter

我愿意在 RAML 中定义一个查询参数,即 map[string][]string,但我不知道如何定义它。我没有使用示例,而是 API Designer 没有按照我的定义显示它。

我的问题:为什么 API Designer 中没有显示查询参数的示例?

示例:

#%RAML 1.0

title: sample API
baseUri: http://localhost:3000/api/{version}
version: v1
protocols: [http]
mediaType: application/json

traits:
    filterProducts: 
        usage: filter products
        queryParameters: 
            filters:
                displayName: filters
                type: object
                description: filter returned products
                examples:
                    required-general-filters: {
                        "page": 1,
                        "limit": 10,
                    }
                    filter-based-on-product-id: {
                        "productId": 123,
                        "returnedProducts": ["similar", "related", "buyed"],
                    }
                required: true
resourceTypes:
    products: 
        get: 
            is: [FilterTraits.filterProducts]
            description: get all products
            responses: 
                200:
                    body:
                        application/json:
                            example: {
                                    success: true,
                                    data: "data",
                                    error: null,
                                }
/products:
    type: {ResourceTypes.products}

我明白了。您可以简单地将查询字符串定义为 RAML 中的一种类型,然后像这样在查询参数中使用它:

#%RAML 1.0

types:
  filterCollection:
    description: filter collection query strings
    properties:
      hasSell:
        description: collection has sell
        type: boolean
        required: false
        example: true
      minSell:
        description: collection total sell is greater than minSell
        type: number
        required: false
        example: 10

traits:
  filters:
    usage: getting products based on query parameters.
    queryParameters:
      pid:
        displayName: Product Id
        type: string
        required: false
      filter:
        type: Types.filters
/product:
  type: { ResourceTypes.Collection }
  is: [filters]
  put: