DMTF / Redfish-JsonSchema-ResponseValidator

The Redfish JSON Schema Response Validator is a Python3 utility used to validate any JSON resource against DMTF provided JSON schemas
Other
3 stars 6 forks source link

Enhanced Reporting mechanism HTML #7

Closed pradeep-bose closed 3 months ago

pradeep-bose commented 6 years ago

As of now , after running a test , we get the below summary

1 resources validated. 0 errors schemas returned from GET 1 schemas returned from cache 0

Is it possible to utilize the existing code and provide values like in Redfish service validator
which has a conformance report in HTML , which is very comprehensive

titles = ['Property Name', 'Value', 'Type', 'Exists', 'Result']

If we have the data output similar to Redfish service validator , then the snippet below can be used to spew a HTML report ? https://github.com/DMTF/Redfish-Service-Validator/blob/master/tohtml.py

billdodd commented 6 years ago

This Redfish-JsonSchema-ResponseValidator tool uses the jsonschema package to perform the validation. And the data output from jsonschema is very different from the output generated by Redfish-Service-Validator. So reusing the tohtml.py from that tool would (I think) not be practical.

pradeep-bose commented 5 years ago

Thanks @billdodd i just wanted some more verbose like information . The current verbose is not so detailed , it just provides the URL data and the schema that was verified. Not all the properties that were verified. I am pretty new to Draft4Validator function in jsonschema library.

So i wanted to get a code snippet to spew out all the items in the data / payload from the URI that were validated , even the PASS ones .

The code snippet below flags only the false ones, I had gone through the jsonschema validator object but couldnt find anything that shows what was passed and value matched with schema (somrthing more verbose )

Could you point me to the right python module / function

import jsonschema
from json import loads

with open ('Memory.v1_6_0.json','r') as fp:
    schema_data = loads (fp.read())
with open ('memory_dimm.json','r') as fp:
    memory_data = loads (fp.read())

try:

    validator = jsonschema.Draft4Validator(schema_data)
    print("Validator information ", validator)
    #validator.validate(memory_data)

    errors_found = []
    for error in validator.iter_errors(memory_data):
        errors_found.append(error.message)

except jsonschema.ValidationError as e:
    print (e.message)

print(errors_found)

#jsonschema.validate(memory_data, schema_data)
print("Value of instance check ",jsonschema.Draft4Validator(schema_data).is_valid(memory_data))
pradeep-bose commented 5 years ago

agreed @billdodd , but some comprehensive report would be a good feature

billdodd commented 5 years ago

@pradeep-bose - the mechanism you show showed above to loop through the errors (which is basically what is on the jsonschema website) is the only way I know to control the output of the default validator. But as you noted, it will only show you the errors.

There is an extension mechanism that could be investigated to see if there is a way to output information on passing results. But I haven't played with it and do not know how feasible that would be.

Creating or Extending Validator Classes

mraineri commented 3 months ago

At this time we're archiving this project in favor of the Redfish Service Validator found here: https://github.com/DMTF/Redfish-Service-Validator