@@ -34,15 +34,15 @@ describe('常规', () => {
3434 required : [ 'foo' ] ,
3535 } ,
3636 } ) ;
37- expect ( type ) . toMatchInlineSnapshot ( `"((({ foo: (string) }))[])"` ) ;
37+ expect ( type ) . toMatchInlineSnapshot ( `"((({ " foo" : (string) }))[])"` ) ;
3838 } ) ;
3939
4040 test ( '对象' , ( ) => {
4141 const type = parseSchema ( docs , {
4242 type : 'object' ,
4343 properties : { foo : { type : 'string' } } ,
4444 } ) ;
45- expect ( type ) . toMatchInlineSnapshot ( `"({ foo?: (string) })"` ) ;
45+ expect ( type ) . toMatchInlineSnapshot ( `"({ " foo" ?: (string) })"` ) ;
4646 } ) ;
4747
4848 test ( '对象属性包含描述' , ( ) => {
@@ -55,10 +55,18 @@ describe('常规', () => {
5555 /**
5656 * foo=bar
5757 */
58- foo?: (string) })"
58+ " foo" ?: (string) })"
5959 ` ) ;
6060 } ) ;
6161
62+ test ( '对象属性包含特殊字符' , ( ) => {
63+ const type = parseSchema ( docs , {
64+ type : 'object' ,
65+ properties : { '123foo' : { type : 'string' } } ,
66+ } ) ;
67+ expect ( type ) . toMatchInlineSnapshot ( `"({ "123foo"?: (string) })"` ) ;
68+ } ) ;
69+
6270 test ( '空对象' , ( ) => {
6371 const type = parseSchema ( docs , { type : 'object' } ) ;
6472 expect ( type ) . toMatchInlineSnapshot ( `"({ })"` ) ;
@@ -98,7 +106,7 @@ describe('oneOf', () => {
98106 ] ,
99107 } ) ;
100108 expect ( type ) . toMatchInlineSnapshot (
101- `"((((({ foo?: (string) }) | ({ bar: (string) })))))"` ,
109+ `"((((({ " foo" ?: (string) }) | ({ " bar" : (string) })))))"` ,
102110 ) ;
103111 } ) ;
104112
@@ -132,7 +140,7 @@ describe('anyOf', () => {
132140 ] ,
133141 } ) ;
134142 expect ( type ) . toMatchInlineSnapshot (
135- `"((((({ foo?: (string) }) | ({ bar: (string) })))))"` ,
143+ `"((((({ " foo" ?: (string) }) | ({ " bar" : (string) })))))"` ,
136144 ) ;
137145 } ) ;
138146
@@ -166,7 +174,7 @@ describe('allOf', () => {
166174 ] ,
167175 } ) ;
168176 expect ( type ) . toMatchInlineSnapshot (
169- `"(((({ foo?: (string) }) & ({ bar: (string) }))))"` ,
177+ `"(((({ " foo" ?: (string) }) & ({ " bar" : (string) }))))"` ,
170178 ) ;
171179 } ) ;
172180
@@ -196,7 +204,7 @@ describe('allOf + anyOf + oneOf', () => {
196204 ] ,
197205 } ) ;
198206 expect ( type ) . toMatchInlineSnapshot (
199- `"((((({ foo2?: (string) }) | ({ bar2?: (string) })) | (({ foo1?: (string) }) | ({ bar1?: (string) }))) & (({ foo: (string) }) & ({ bar?: (string) }))))"` ,
207+ `"((((({ " foo2" ?: (string) }) | ({ " bar2" ?: (string) })) | (({ " foo1" ?: (string) }) | ({ " bar1" ?: (string) }))) & (({ " foo" : (string) }) & ({ " bar" ?: (string) }))))"` ,
200208 ) ;
201209 } ) ;
202210
@@ -208,7 +216,7 @@ describe('allOf + anyOf + oneOf', () => {
208216 oneOf : [ { properties : { foo : { type : 'string' } } , required : [ 'foo' ] } ] ,
209217 } ) ;
210218 expect ( type ) . toMatchInlineSnapshot (
211- `"((((({ foo: (string) }))) & (({ foo2?: (string) }))))"` ,
219+ `"((((({ " foo" : (string) }))) & (({ " foo2" ?: (string) }))))"` ,
212220 ) ;
213221 } ) ;
214222
@@ -219,7 +227,7 @@ describe('allOf + anyOf + oneOf', () => {
219227 anyOf : [ { properties : { foo2 : { type : 'string' } } , required : [ 'foo' ] } ] ,
220228 oneOf : [ { properties : { foo : { type : 'string' } } , required : [ 'foo' ] } ] ,
221229 } ) ;
222- expect ( type ) . toMatchInlineSnapshot ( `"((((({ foo: (string) })))))"` ) ;
230+ expect ( type ) . toMatchInlineSnapshot ( `"((((({ " foo" : (string) })))))"` ) ;
223231 } ) ;
224232
225233 test ( 'anyOf = allOf' , ( ) => {
@@ -229,7 +237,7 @@ describe('allOf + anyOf + oneOf', () => {
229237 anyOf : [ { properties : { foo : { type : 'string' } } , required : [ 'foo' ] } ] ,
230238 oneOf : [ { properties : { foo2 : { type : 'string' } } , required : [ 'foo' ] } ] ,
231239 } ) ;
232- expect ( type ) . toMatchInlineSnapshot ( `"((((({ foo: (string) })))))"` ) ;
240+ expect ( type ) . toMatchInlineSnapshot ( `"((((({ " foo" : (string) })))))"` ) ;
233241 } ) ;
234242
235243 test ( 'oneOf = anyOf = allOf' , ( ) => {
@@ -239,7 +247,7 @@ describe('allOf + anyOf + oneOf', () => {
239247 anyOf : [ { properties : { foo : { type : 'string' } } , required : [ 'foo' ] } ] ,
240248 oneOf : [ { properties : { foo : { type : 'string' } } , required : [ 'foo' ] } ] ,
241249 } ) ;
242- expect ( type ) . toMatchInlineSnapshot ( `"((((({ foo: (string) })))))"` ) ;
250+ expect ( type ) . toMatchInlineSnapshot ( `"((((({ " foo" : (string) })))))"` ) ;
243251 } ) ;
244252} ) ;
245253
@@ -286,7 +294,7 @@ describe('nullable', () => {
286294 type : 'object' ,
287295 properties : { foo : { type : 'string' , nullable : true } } ,
288296 } ) ,
289- ) . toMatchInlineSnapshot ( `"({ foo?: (string | null) })"` ) ;
297+ ) . toMatchInlineSnapshot ( `"({ " foo" ?: (string | null) })"` ) ;
290298 } ) ;
291299
292300 test ( '二进制' , ( ) => {
0 commit comments