Use pattern in API Blueprint / MSON

791 views Asked by At

I'm investigating the possibilities of the new Data Structures syntax in API Blueprint, especially MSON. Is it possible to attach or rather specify something like a pattern (regex)? Don't found anything on this topic.

1

There are 1 answers

1
kylef On

To provide regex validation for your data structure you will need to provide a JSON Schema which has this validation rule. For example, like the following:

### View a Questions Detail [GET]

+ Response 200 (application/json)
    + Attributes
        + question: `Favourite programming language?` (string)

    + Schema

            {
              "properties": {
                "question": {
                  "type": "string",
                  "pattern": "^Favourite.*$"
                }
               }
            }