@@ -46,10 +46,6 @@ func TestReference_Validate_Success(t *testing.T) {
4646 name : "JSON pointer with array index" ,
4747 ref : "#/paths/~1users~1{id}/get/responses/200/content/application~1json/examples/0" ,
4848 },
49- {
50- name : "JSON pointer with escaped characters" ,
51- ref : "#/components/schemas/User~1Profile/properties/user~0name" ,
52- },
5349 {
5450 name : "file URI" ,
5551 ref : "file:///path/to/schema.yaml#/User" ,
@@ -103,6 +99,41 @@ func TestReference_Validate_Error(t *testing.T) {
10399 ref : "https://example .com/api.yaml#/User" ,
104100 expectError : "invalid reference URI" ,
105101 },
102+ {
103+ name : "empty component name - schemas" ,
104+ ref : "#/components/schemas/" ,
105+ expectError : "component name cannot be empty" ,
106+ },
107+ {
108+ name : "empty component name - parameters" ,
109+ ref : "#/components/parameters/" ,
110+ expectError : "component name cannot be empty" ,
111+ },
112+ {
113+ name : "empty component name - responses" ,
114+ ref : "#/components/responses/" ,
115+ expectError : "component name cannot be empty" ,
116+ },
117+ {
118+ name : "missing component name - schemas" ,
119+ ref : "#/components/schemas" ,
120+ expectError : "component name cannot be empty" ,
121+ },
122+ {
123+ name : "component name with space" ,
124+ ref : "#/components/schemas/User Schema" ,
125+ expectError : "must match pattern" ,
126+ },
127+ {
128+ name : "component name with special characters" ,
129+ ref : "#/components/schemas/User@Schema" ,
130+ expectError : "must match pattern" ,
131+ },
132+ {
133+ name : "component name starting with slash" ,
134+ ref : "#/components/schemas//UserSchema" ,
135+ expectError : "component name cannot be empty" ,
136+ },
106137 }
107138
108139 for _ , tt := range tests {
0 commit comments