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.
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
GenerateSchemaForTypeto detect and remove a root$ref, merging its definitions into the root schema. - Introduce a
containsRefhelper to detect circular references when flattening. - Extend
TestStructToSchemawith 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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 <175728472+Copilot@users.noreply.github.com> * Update jsonschema/json.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
#1030