I’m not seeing any discussion in the RAML 1.0 spec re. how to define a query parameter that either a) cannot have a value, or b) can optionally have a value e.g.
Is this a gap in the spec itself, or in the docs?
I’m not seeing any discussion in the RAML 1.0 spec re. how to define a query parameter that either a) cannot have a value, or b) can optionally have a value e.g.
Is this a gap in the spec itself, or in the docs?
As I know in http://example.com/foo?bar
value of bar is empty string. So we can write this:
#%RAML 1.0
title: Illustrating queries
mediaType: application/json
/foo:
get:
queryParameters:
bar:
description: Query parameter, what can not have value
type: string
maxLength: 0
Hi @rocketraman, you could either define that as @galkin suggested. In RC2 we introduced the null
type, but as you might know; normally only the string “null” in a query parameter context gets deserialized into the null
type.
https://github.com/raml-org/raml-spec/blob/raml-10/versions/raml-10/raml-10.md#null-type
you can try the following if you want to make your query parameter not mandatory using required: false
… for example : -
#%RAML 1.0
title: test
baseUri: http://example.com
version: 1.0
mediaType: application/json
/foo:
description: Service to receive some details
get:
description: Get Service.
queryParameters:
bar:
displayName: bar
type: string
description: your feild description
example: Anirban
required: false