Closed alirankine-dojo closed 11 months ago
Describe the bug When using InlineRefs, multiple properties of the same type leave all but one fields without an inline definition.
To Reproduce When running the following code:
package jstest import ( "encoding/json" "testing" "github.com/swaggest/jsonschema-go" ) type ExampleEvent struct { ID string `json:"id,omitempty"` NewData Data `json:"new_data"` CurrentData Data `json:"current_data"` OldData Data `json:"old_data"` } type Data struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` } func TestRaw(t *testing.T) { ref := jsonschema.Reflector{} gen, _ := ref.Reflect(&ExampleEvent{}, func(rc *jsonschema.ReflectContext) { rc.InlineRefs = true }) data, _ := json.MarshalIndent(gen, "", " ") t.Error(string(data)) }
The following schema is produced:
{ "properties": { "current_data": {}, "id": { "type": "string" }, "new_data": { "properties": { "id": { "type": "string" }, "name": { "type": "string" } }, "type": "object" }, "old_data": {} }, "type": "object" }
Expected behavior An inline definition should be produced for each of the 'current_data', 'new_data', old_data' fields
Thank you for reporting this, please try new v0.3.53.
v0.3.53
Describe the bug When using InlineRefs, multiple properties of the same type leave all but one fields without an inline definition.
To Reproduce When running the following code:
The following schema is produced:
Expected behavior An inline definition should be produced for each of the 'current_data', 'new_data', old_data' fields