Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use pattern in API Blueprint / MSON

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.

like image 386
loxy Avatar asked Aug 05 '15 11:08

loxy


1 Answers

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.*$"
                }
               }
            }
like image 113
kylef Avatar answered Oct 15 '22 08:10

kylef