Enhancements to JSON Schema Generation in speckle_automate#347
Open
jsdbroughton wants to merge 1 commit intomainfrom
Open
Enhancements to JSON Schema Generation in speckle_automate#347jsdbroughton wants to merge 1 commit intomainfrom
speckle_automate#347jsdbroughton wants to merge 1 commit intomainfrom
Conversation
Adds additional processing the the OOTB GenerateJsonSchema for types created in pydantic that moves the requirement from users function to the SDK
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
AutomateGenerateJsonSchemaclass and better handling of schema properties.Detailed Changes:
AutomateGenerateJsonSchemaClass:AutomateGenerateJsonSchemaclass 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_typestatic 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.