@@ -23,7 +23,7 @@ func findByPath(findings []Finding, path string) (Finding, bool) {
2323func TestDiffRequiredAdded (t * testing.T ) {
2424 oldRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"}}}` )
2525 newRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"}},"required":["a"]}` )
26- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
26+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
2727 if ! HasBreaking (findings ) {
2828 t .Fatalf ("expected breaking finding, got %+v" , findings )
2929 }
@@ -36,7 +36,7 @@ func TestDiffRequiredAdded(t *testing.T) {
3636func TestDiffPropertyRemoved (t * testing.T ) {
3737 oldRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"},"b":{"type":"integer"}}}` )
3838 newRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"}}}` )
39- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
39+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
4040 if ! HasBreaking (findings ) {
4141 t .Fatalf ("expected breaking finding, got %+v" , findings )
4242 }
@@ -49,7 +49,7 @@ func TestDiffPropertyRemoved(t *testing.T) {
4949func TestDiffTypeChanged (t * testing.T ) {
5050 oldRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"}}}` )
5151 newRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"integer"}}}` )
52- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
52+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
5353 if ! HasBreaking (findings ) {
5454 t .Fatalf ("expected breaking finding, got %+v" , findings )
5555 }
@@ -65,20 +65,20 @@ func TestDiffEnumDirectional(t *testing.T) {
6565 narrowed := mustRaw (t , `{"type":"object","properties":{"level":{"type":"string","enum":["low"]}}}` )
6666 expanded := mustRaw (t , `{"type":"object","properties":{"level":{"type":"string","enum":["low","high","critical"]}}}` )
6767
68- // input_schema :收窄 = breaking(旧调用发被删值会被拒)
69- if findings := DiffSchemas ("input_schema " , oldRaw , narrowed ); ! HasBreaking (findings ) {
68+ // inputSchema :收窄 = breaking(旧调用发被删值会被拒)
69+ if findings := DiffSchemas ("inputSchema " , oldRaw , narrowed ); ! HasBreaking (findings ) {
7070 t .Fatalf ("input enum narrowing should be breaking, got %+v" , findings )
7171 }
72- // input_schema :扩张 = compatible(旧调用方不受影响)
73- if findings := DiffSchemas ("input_schema " , oldRaw , expanded ); HasBreaking (findings ) {
72+ // inputSchema :扩张 = compatible(旧调用方不受影响)
73+ if findings := DiffSchemas ("inputSchema " , oldRaw , expanded ); HasBreaking (findings ) {
7474 t .Fatalf ("input enum expansion should be compatible, got %+v" , findings )
7575 }
76- // output_schema :扩张 = breaking(消费方会见到新值)
77- if findings := DiffSchemas ("output_schema " , oldRaw , expanded ); ! HasBreaking (findings ) {
76+ // outputSchema :扩张 = breaking(消费方会见到新值)
77+ if findings := DiffSchemas ("outputSchema " , oldRaw , expanded ); ! HasBreaking (findings ) {
7878 t .Fatalf ("output enum expansion should be breaking, got %+v" , findings )
7979 }
80- // output_schema :收窄 = compatible
81- if findings := DiffSchemas ("output_schema " , oldRaw , narrowed ); HasBreaking (findings ) {
80+ // outputSchema :收窄 = compatible
81+ if findings := DiffSchemas ("outputSchema " , oldRaw , narrowed ); HasBreaking (findings ) {
8282 t .Fatalf ("output enum narrowing should be compatible, got %+v" , findings )
8383 }
8484}
@@ -87,7 +87,7 @@ func TestDiffEnumDirectional(t *testing.T) {
8787func TestDiffCompatibleChanges (t * testing.T ) {
8888 oldRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string","title":"A"}},"required":["a"]}` )
8989 newRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string","title":"A","description":"field a"},"b":{"type":"integer"}},"required":["a"]}` )
90- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
90+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
9191 if HasBreaking (findings ) {
9292 t .Fatalf ("expected only compatible findings, got %+v" , findings )
9393 }
@@ -100,18 +100,18 @@ func TestDiffCompatibleChanges(t *testing.T) {
100100func TestDiffStructureTypeChanged (t * testing.T ) {
101101 oldRaw := mustRaw (t , `{"type":"object","properties":{"profile":{"type":"object"}}}` )
102102 newRaw := mustRaw (t , `{"type":"object","properties":{"profile":{"type":"string"}}}` )
103- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
103+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
104104 if ! HasBreaking (findings ) {
105105 t .Fatalf ("expected breaking finding, got %+v" , findings )
106106 }
107107}
108108
109109// 首次注册(旧 schema 为空)与非法 JSON 不产生差异
110110func TestDiffEmptyAndInvalid (t * testing.T ) {
111- if findings := DiffSchemas ("input_schema " , nil , mustRaw (t , `{"type":"object"}` )); len (findings ) != 0 {
111+ if findings := DiffSchemas ("inputSchema " , nil , mustRaw (t , `{"type":"object"}` )); len (findings ) != 0 {
112112 t .Fatalf ("expected no findings for initial registration, got %+v" , findings )
113113 }
114- if findings := DiffSchemas ("input_schema " , mustRaw (t , `not-json` ), mustRaw (t , `{"type":"object"}` )); len (findings ) != 0 {
114+ if findings := DiffSchemas ("inputSchema " , mustRaw (t , `not-json` ), mustRaw (t , `{"type":"object"}` )); len (findings ) != 0 {
115115 t .Fatalf ("expected no findings for invalid old schema, got %+v" , findings )
116116 }
117117}
@@ -120,7 +120,7 @@ func TestDiffEmptyAndInvalid(t *testing.T) {
120120func TestDiffNestedBreaking (t * testing.T ) {
121121 oldRaw := mustRaw (t , `{"type":"object","properties":{"profile":{"type":"object","properties":{"city":{"type":"string"}}}}}` )
122122 newRaw := mustRaw (t , `{"type":"object","properties":{"profile":{"type":"object","properties":{}}}}` )
123- findings := DiffSchemas ("input_schema " , oldRaw , newRaw )
123+ findings := DiffSchemas ("inputSchema " , oldRaw , newRaw )
124124 if ! HasBreaking (findings ) {
125125 t .Fatalf ("expected nested breaking finding, got %+v" , findings )
126126 }
@@ -132,8 +132,8 @@ func TestDiffNestedBreaking(t *testing.T) {
132132// source 区分 input/output
133133func TestDiffSourceLabels (t * testing.T ) {
134134 oldRaw := mustRaw (t , `{"type":"object","properties":{"a":{"type":"string"}}}` )
135- findings := DiffSchemas ("output_schema " , oldRaw , mustRaw (t , `{"type":"object","properties":{}}` ))
136- if len (findings ) != 1 || findings [0 ].Source != "output_schema " {
137- t .Fatalf ("expected single output_schema finding, got %+v" , findings )
135+ findings := DiffSchemas ("outputSchema " , oldRaw , mustRaw (t , `{"type":"object","properties":{}}` ))
136+ if len (findings ) != 1 || findings [0 ].Source != "outputSchema " {
137+ t .Fatalf ("expected single outputSchema finding, got %+v" , findings )
138138 }
139139}
0 commit comments