Enhancements to JSON Schema Generation in speckle_automate
#347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improvements to the JSON schema generation functionality within the speckle_automate module. The key change is enhancements to the
AutomateGenerateJsonSchema
class and better handling of schema properties.Detailed Changes:
AutomateGenerateJsonSchema
Class:AutomateGenerateJsonSchema
class inherits directly from GenerateJsonSchema as before but now includes additional logic for handling properties and definitions ($defs).Addition of _process_property Method:
This private method handles properties within the JSON schema, particularly for processing enum, default, and type attributes. It includes logic to infer the type of properties and to handle specific scenarios where properties reference other schemas via
$ref
.Enhanced Type Inference:
The
_infer_type
static method was added to handle type inference for various field types (bool
,int
,float
,str
). This method ensures that the correct JSON types are assigned to schema properties based on the Python field types. This was already performed to a degree, but I wanted to ensure I hadn't overridden something stupid.Removed Redundant AutomateGenerateJsonSchema Class:
The previous version of AutomateGenerateJsonSchema has been removed to eliminate redundancy, as the new implementation now handles all required functionality.