v2.1.1: JSONSchemaBytes returns json.RawMessage
Changed
Schema.JSONSchemaBytes() now returns json.RawMessage instead of []byte.
Why: json.RawMessage is []byte underneath, but implements json.Marshaler — so when you embed a schema in a JSON struct, it serializes as raw JSON instead of being base64-encoded:
type APIResponse struct {
Schema json.RawMessage `json:"schema"` // ✓ embeds as {"type":"object",...}
}
// Before ([]byte): {"schema":"eyJ0eXBlIjoib2JqZWN0In0="} ← base64 garbage
// After (json.RawMessage): {"schema":{"type":"object",...}} ← correctMigration: Since json.RawMessage is type RawMessage []byte, most code works unchanged. Only explicit []byte type assertions on the return value need updating:
// Before
b := myType.JSONSchemaBytes() // still works — json.RawMessage IS []byte
// Only this pattern breaks:
var _ []byte = myType.JSONSchemaBytes() // ← needs json.RawMessage