breaking: refactor GTS macro API: rename methods, add instance serialization, hide internals#26
Merged
Artifizer merged 11 commits intoGlobalTypeSystem:mainfrom Dec 26, 2025
Merged
Conversation
…to be type-parameter independent
When a generic base struct (e.g., TopicV1<P>) was instantiated with a
concrete type parameter (e.g., TopicV1<OrderTopicConfigV1>), it incorrectly
generated a different schema than TopicV1<()>, using the innermost type's
schema ID and incorrectly adding an allOf structure.
Changes:
- Use Self::SCHEMA_ID instead of Self::innermost_schema_id() to determine
the struct's own schema ID and parent relationship
- Get properties from schemars::schema_for!(Self) for the current struct
rather than recursively fetching the innermost type's schema
- Replace generic fields with {"type": "object"} placeholders regardless
of the concrete type parameter used
- Add test_generic_base_struct_schema_consistency() to verify that
TopicV1<()> and TopicV1<OrderTopicConfigV1> generate identical schemas
This ensures that generic base structs always generate their own base schema
consistently, with the type parameter only affecting compile-time type safety
but not the generated schema structure.
Signed-off-by: Artifizer <artifizer@gmail.com>
…ization, hide internals API changes: - Add gts_base_schema_id() returning Option<&'static GtsSchemaId> - Add gts_instance_json(&self) returning serde_json::Value - Add gts_instance_json_as_string(&self) returning compact JSON String - Add gts_instance_json_as_string_pretty(&self) returning pretty JSON String - Automatically add needed derive(...) - Rename gts_json_schema_with_refs() to gts_schema_with_refs_as_string() - Rename gts_json_schema_with_refs_pretty() to gts_schema_with_refs_as_string_pretty() - Rename make_gts_instance_id() -> gts_make_instance_id() for "gts_" prefix consistency - Make SCHEMA_ID and BASE_SCHEMA_ID constants private (use methods instead) Update tests and README documentation with new API. Signed-off-by: Artifizer <artifizer@gmail.com>
Signed-off-by: Artifizer <artifizer@gmail.com>
…done in macro Signed-off-by: Artifizer <artifizer@gmail.com>
- Add `json_schema_value()` methods to `GtsInstanceId` and `GtsSchemaId` in `gts/src/gts.rs` that return canonical JSON Schema representations - Update `schemars::JsonSchema` implementations to use these shared methods, eliminating code duplication - Update CLI schema generator (`gts-cli/src/gen_schemas.rs`) to use shared functions instead of duplicating schema definitions - Export `GtsSchemaId` from `gts/src/lib.rs` for CLI usage - Fix schema scanner to properly generate schemas with `x-gts-ref` extensions for GTS types This ensures a single source of truth for GTS type schema definitions, making them easier to maintain and ensuring consistency between the macro-generated schemas and CLI-generated schemas. Generated schema files are included as examples of the scanner output. Signed-off-by: Artifizer <artifizer@gmail.com>
Signed-off-by: Artifizer <artifizer@gmail.com>
Signed-off-by: Artifizer <artifizer@gmail.com>
Signed-off-by: Artifizer <artifizer@gmail.com>
…ake code and logic cleaner Signed-off-by: Artifizer <artifizer@gmail.com>
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.
chore: Makefile - added 'generate-schemas' target
refactor: extract GTS type schema definitions into shared functions
breaking: refactor GTS macro API: rename methods, add instance serialization, hide internals
fix(struct_to_gts_schema): fix generic base struct schema generation to be type-parameter independent