Skip to content

Feat/gts spec v0.7#13

Merged
Artifizer merged 2 commits intoGlobalTypeSystem:mainfrom
KvizadSaderah:feat/gts-spec-v0.7
Dec 23, 2025
Merged

Feat/gts spec v0.7#13
Artifizer merged 2 commits intoGlobalTypeSystem:mainfrom
KvizadSaderah:feat/gts-spec-v0.7

Conversation

@KvizadSaderah
Copy link
Copy Markdown
Contributor

Description

Implementation of gts-spec v0.7 breaking changes for Python.

Related Issues

Closes GlobalTypeSystem/gts-spec#25
Closes GlobalTypeSystem/gts-spec#31
Closes GlobalTypeSystem/gts-spec#32

Changes

Issue #25: Never use GTS ID in $schema

  • Strict $schema validation rejects gts.* and gts:// URIs
  • Only JSON Schema URLs (http://json-schema.org/...) allowed
  • Implemented in _is_json_schema_entity() and validate_schema()

Issue #31: Normalize gts:// prefix in $id

  • Strip gts:// prefix automatically when parsing ID fields
  • Applies to all entity_id_fields and schema_id_fields
  • Transparent normalization during entity construction

Issue #32: Strict $ref validation

  • New _validate_schema_refs() method enforces URI-compatible refs
  • Require gts:// prefix for external GTS schema references
  • Allow local JSON Pointer refs (#/definitions/...)
  • Reject bare GTS IDs, HTTP URLs, and malformed identifiers
  • Validation integrated as first step in validate_schema()

Testing

  • ✅ 11 comprehensive tests covering all edge cases
  • ✅ All tests pass (run with python test_changes.py -v)
  • ✅ Validated against reference implementations

Reference Implementations

Implement Issues #25, #31, #32 from gts-spec v0.7:

Issue #25: Never use GTS ID in $schema
- Strict validation in _is_json_schema_entity()
- Reject gts.* IDs and gts:// URIs in $schema field
- Only JSON Schema URLs allowed

Issue #31: Normalize gts:// prefix in $id
- Strip gts:// prefix in _get_field_value()
- Applies to all entity_id_fields and schema_id_fields
- Automatic normalization during ID extraction

Issue #32: Strict $ref validation with gts:// requirement
- Add _validate_schema_refs() static method
- Require gts:// prefix for external GTS refs
- Allow local JSON Pointer refs (#/definitions/...)
- Reject bare GTS IDs and HTTP/HTTPS refs
- Integrate into validate_schema() as first validation step

Reference implementations:
- gts-rust PR #19: GlobalTypeSystem/gts-rust#19
- gts-spec PR #33: GlobalTypeSystem/gts-spec#33

Signed-off-by: Dmitrii Efremov <kaidendev@icloud.com>
Update 4 tests in test_entities.py to reflect Issue #25 changes:
- test_default_config: $schema no longer in schema_id_fields
- test_entity_schema_detection_gts_uri: gts:// in $schema NOT recognized as schema
- test_entity_schema_detection_gts_prefix: gts. prefix in $schema NOT recognized as schema
- test_entity_schema_id_calculation: use 'type' field instead of $schema

These tests were checking old behavior (pre-v0.7) where GTS IDs could be used in $schema field.
Per Issue #25, only JSON Schema URLs are allowed in $schema.

All 108 tests pass.

Signed-off-by: Dmitrii Efremov <kaidendev@icloud.com>
@Artifizer Artifizer merged commit 3edda03 into GlobalTypeSystem:main Dec 23, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Always use "gts://" prefix in $ref in JSON Schema Always use '$id' as GTS Schema ID Never use gts ID in JSON Schema $schema

2 participants