Monday, August 31, 2015

JSON Validation by Committee

In my previous post, I went through the paces of creating a JSON Schema to describe the JSON that my service will accept and return. The process leans on the prmd gem to supply the initial JSON Schema templates, as well as validation and document generation. All in all, it's a process that feels like it should be more automated. I went through a fair amount of pain to get the schema created, manually defining types and links in my text editor. At the end of the effort, I have a .json file that describes what my API will accept and return, as well as matching Markdown documentation to boot.

In that post, I made promise of something better. A land where writing unit tests that verify the JSON returned by my Rails API is possible. A land where the production application will reject requests that do not conform to our JSON schema. Does that sound like a wonderful place? It does to me.

This post will build that land, showing you how to feed the schema into tools provided by the committee gem, using those tools to verify tests and application requests.

Continue reading %JSON Validation by Committee%


by Glenn Goodrich via SitePoint

No comments:

Post a Comment