-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Removed root $ref from GenerateSchemaForType #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed root $ref from GenerateSchemaForType #1033
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1033 +/- ##
==========================================
+ Coverage 87.26% 87.41% +0.14%
==========================================
Files 43 43
Lines 2387 2415 +28
==========================================
+ Hits 2083 2111 +28
Misses 284 284
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the top‐level $ref
from generated schemas and flattens definitions, adjusting tests to validate the new behavior.
- Insert logic in
GenerateSchemaForType
to detect and remove a root$ref
, merging its definitions into the root schema. - Introduce a
containsRef
helper to detect circular references when flattening. - Extend
TestStructToSchema
with new types (Person
,MyStructuredResponse
,User
,Order
) and corresponding expected JSON schemas.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
jsonschema/json.go | Implement root $ref removal and add containsRef helper. |
jsonschema/json_test.go | Add tests for Person , MyStructuredResponse , User , and Order schema output. |
@eiixy please lmk if copilot suggestions are legit, otherwise lgtm! |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
The suggestion about field order isn’t an issue — we convert the structToMap before comparing via reflect.DeepEqual, so the order doesn’t affect the result. |
* support $ref and $defs in JSON Schema * update * removed root $ref from JSON Schema * Update json.go * Update json_test.go * Update jsonschema/json.go Co-authored-by: Copilot <[email protected]> * Update jsonschema/json.go Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
#1030