Tags: microsoft/jschema-to-python
Tags
Fix #13: Required property names are not translated to camelCase on o… …utput. For consistency with Python conventions, jschema-to-python maps property names in the JSON schema (which are typically camelCase) to underscore_separated attribute names in the generated Python classes. The generated attributes include metadata that maps the Python property names back to the original JSON schema property names. The to_json method uses this metadata so that object models built with the generated Python classes are correctly serialized to JSON that conforms to the schema. The bug here was that although optional properties contained this metadata, required properties did not. This meant that if a required JSON schema property consisted of more than one word (for example, "fileChanges"), the Python object containing that property would be serialized as "file_changes".
Address review feedback from MS Python team. (#3) * Remove unnecessary calls to keys(). * Rely on truthiness checks. * Use dict.get(key) instead of if key in dict. * Print to sys.stdout instead of using self.file_obj.write. * Underscores to hyphens in setup.cfg. * Replace .format() print(x + y + z). * Don't create output directory in initializer. * Specify mode and encoding on all open() calls * Use repr instead of custom util.quote. * Use conventional module names * DRY out construction of class module name. * Use TypeError for missing arguments. * Test "if missing_properties", not len(). * Add back a period. * Remove format() calls in driver.py.
PreviousNext