I am willing defining an query parameter in RAML that is map[string][]string, But i don't know how to define it. Instead of that i use examples, but API Designer does not show it as i define.
my question: why query parameter's example does not shown in API Designer?
example:
#%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}
I figure it out. you can simply define your query string as a type in RAML and then use it in your query parameter like this:
#%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: