Consider this excerpt from https://github.com/apiaryio/mson#example-1 ...
A simple object
structure and its associated JSON expression.
- id: 1
- name: A green door
- price: 12.50
- tags: home, green
Let's say I would like to define valid values for the name
attribute. Consider a context of API testing with a tool such as Dredd. We may need to define what are the expected/valid name
values in response to GET'ing this resource, or else something is probably broken and this test step should fail.
And/or, if creating/updating a resource of this type, we may need to define what name
values are valid/accepted. Is this currently possible to define in MSON?
(I believe this can be done in a JSON schema, which makes me hopeful for MSON support.)
Following is an example API Blueprint resource to illustrate how this would be used...
# Thing ID [/api/thing/id]
# List Thing ID attributes [GET]
+ Response 200
+ Attributes
+ href (string)
+ make (string)
+ model (string)
+ version (string)
+ Body
{"href":"/api/thing/id","make":"BrandX","model":"SuperThingy","version":"10.1"}
In the above example, there are 3 known/accepted/valid values for the model
attribute: CoolThingy
, AwesomeThingy
, and MLGThingy
Can we represent this resource in MSON, such that...
model
values to expect?model
value in the response to a GET to this resource?In MSON you can use enum, see the example below.
name
(enum[string])
joe
(default)ben
mark