keleshev / schema

Schema validation just got Pythonic
MIT License
2.86k stars 214 forks source link

[Help Needed] how to use online json response to schema converter tools in Pytest_Schema #293

Closed HassanAbbas7357 closed 1 year ago

HassanAbbas7357 commented 1 year ago

Hello there, i have got an api API i copied its json reponse and pasted in this online tool JOSN to Schema converter

i have got a schema now i have created a json file and pasted schema in it

and wanted to use it in Pytest_Schema directly like this

def getSchemafromJSONAndCompareSchema(JsonResp, filename):
    filepath = filename
    with open(filepath, 'r') as f:
        data = json.load(f)

    assert exact_schema(data) == JsonResp
    # schema.validate(JsonResp,data)
    return data

but its not working as i expected can you tell me if its going to work any way? or i have to always create schema objects from Schema class manually?

HassanAbbas7357 commented 1 year ago

i got my solution its jsonschema package that should be used in my case thanks iam closing the issue