University of Victoria (Canada)
Specification-driven generation of type-safe python configuration classes for JSON inputs
Abstract
dc:description.abstractModern scientific and engineering libraries often use JSON configuration files to run simulations and workflows. JSON is readable and widely supported, but real configuration files can be hard to write correctly because they may have deep nesting, lists, optional and required fields, fixed choices, and numeric limits. In many libraries, these rules are described in a separate input specification file, but developers usually create the type-safe interface and validation code by hand. This can repeat the same logic, become inconsistent when the specification changes, and lead to unclear error messages. This thesis introduces a system that takes the JSON input specification as the main reference and automatically generates strongly typed Python configuration classes from it. The generated classes are organized in the same structure as the specification using nested classes, and users can set values with normal attribute access to ensure each value is placed in the correct part of the specification. Validation is built into both the constructors and the property setters. This means whenever a value is given, the system checks its type and rules (for example, valid ranges, allowed options, or required file extensions). It also allows complex parts of the configuration to be filled step by step by setting their child properties. The system shows which fields are required using the generated documentation, and it also provides a report method that finds any missing required values before saving. After the configuration is complete, the objects are converted back into JSON-compatible output that matches the specification by design and can be used by other libraries. Internally, the approach builds an intermediate tree from specification pointers and then generates the class from it. It supports heterogeneous lists with wildcard routing and polymorphic variables with multiple allowable shapes. Robustness is tested by making controlled changes to the specification and running failure-case tests. The results show that the system reliably works with realistic patterns and clearly detects unsupported types and problems when the specification hierarchy is in the wrong order.
Degree
thesis:*- Level thesis:degree_level
- Master of Science MSc
- Department thesis:degree_department
- Department of Computer Science
- Year dc:date.issued
- 2026
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Gilanilarimi, Mohsen
- Advisor dc:contributor.supervisor
-
- Schneider, Teseo
Subjects
dc:subject × 4Rights
dc:rights- Statement dc:rights
-
- Available to the World Wide Web
- Language dc:language.iso
- en, English
Identifiers
dc:identifier.*- Handle dc:identifier.uri
- https://hdl.handle.net/1828/23745