loxy
loxy

Reputation: 373

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.

Upvotes: 6

Views: 799

Answers (1)

kylef
kylef

Reputation: 1066

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.*$"
                }
               }
            }

Upvotes: 5

Related Questions