dimanche 11 mars 2018

Best way to validate json response in python 3

I am using python 3 for functional testing of a bunch of rest endpoints. But i cannot figure out the best way to validate the json reaponse ( verifying the type, required, missing and additional fields)

I thought of below options : 1. Writing custom code and validate the response while converting the data into python class objects. 2. Validate using json schema .

Option 1: would be difficult to maintain and need to add separate functions to all the data models. Option 2 : i like it. But i dont want to write schema for each endpoint in separate file/object. Is there a way to put it in a single object like we have swagger yml file. That way would be easy to maintain.

I would like to know which option is the best and if there are other better options / libraries available.

Aucun commentaire:

Enregistrer un commentaire