File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -129,12 +129,13 @@ export default function transformOperationObject(
129
129
output . push ( indent ( `responses: {` , indentLv ) ) ;
130
130
indentLv ++ ;
131
131
for ( const [ responseCode , responseObject ] of getEntries ( operationObject . responses , ctx . alphabetize ) ) {
132
+ const key = escObjKey ( responseCode ) ;
132
133
const c = getSchemaObjectComment ( responseObject , indentLv ) ;
133
134
if ( c ) output . push ( indent ( c , indentLv ) ) ;
134
135
if ( "$ref" in responseObject ) {
135
136
output . push (
136
137
indent (
137
- `${ responseCode } : ${ transformSchemaObject ( responseObject , {
138
+ `${ key } : ${ transformSchemaObject ( responseObject , {
138
139
path : `${ path } /responses/${ responseCode } ` ,
139
140
ctx,
140
141
} ) } ;`,
@@ -146,7 +147,7 @@ export default function transformOperationObject(
146
147
path : `${ path } /responses/${ responseCode } ` ,
147
148
ctx : { ...ctx , indentLv } ,
148
149
} ) ;
149
- output . push ( indent ( `${ responseCode } : ${ responseType } ;` , indentLv ) ) ;
150
+ output . push ( indent ( `${ key } : ${ responseType } ;` , indentLv ) ) ;
150
151
}
151
152
}
152
153
indentLv -- ;
Original file line number Diff line number Diff line change @@ -39,6 +39,21 @@ describe("Path Item Object", () => {
39
39
} ,
40
40
} ,
41
41
404 : { $ref : 'components["responses"]["NotFound"]' } ,
42
+ "5xx" : {
43
+ description : "Server error" ,
44
+ content : {
45
+ "application/json" : {
46
+ schema : {
47
+ type : "object" ,
48
+ properties : {
49
+ message : { type : "string" } ,
50
+ code : { type : "string" } ,
51
+ } ,
52
+ required : [ "message" ] ,
53
+ } ,
54
+ } ,
55
+ } ,
56
+ } ,
42
57
} ,
43
58
} ,
44
59
post : {
@@ -66,6 +81,15 @@ describe("Path Item Object", () => {
66
81
};
67
82
};
68
83
404: components["responses"]["NotFound"];
84
+ /** @description Server error */
85
+ "5xx": {
86
+ content: {
87
+ "application/json": {
88
+ message: string;
89
+ code?: string;
90
+ };
91
+ };
92
+ };
69
93
};
70
94
};
71
95
post: {
You can’t perform that action at this time.
0 commit comments