File tree Expand file tree Collapse file tree
openapi-typescript-plugin/src/__snapshots__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @openapi-qraft/test-fixtures ' : patch
3+ ' @openapi-qraft/plugin ' : patch
4+ ---
5+
6+ Add support for responses with ` $ref ` specification.
Original file line number Diff line number Diff line change @@ -174,7 +174,17 @@ export interface components {
174174 url : string ;
175175 } ;
176176 } ;
177- responses : never ;
177+ responses : {
178+ /** @description Unexpected error */
179+ DefaultErrorSchemaResponse : {
180+ headers : {
181+ [ name : string ] : unknown ;
182+ } ;
183+ content : {
184+ "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
185+ } ;
186+ } ;
187+ } ;
178188 parameters : {
179189 IdIn : string [ ] ;
180190 /** @example 2023-06-04 */
@@ -262,15 +272,7 @@ export interface operations {
262272 "application/json" : components [ "schemas" ] [ "HTTPValidationError" ] ;
263273 } ;
264274 } ;
265- /** @description Unexpected error */
266- default : {
267- headers : {
268- [ name : string ] : unknown ;
269- } ;
270- content : {
271- "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
272- } ;
273- } ;
275+ default : components [ "responses" ] [ "DefaultErrorSchemaResponse" ] ;
274276 } ;
275277 } ;
276278 get_approval_policies_id : {
@@ -514,15 +516,7 @@ export interface operations {
514516 "application/json" : components [ "schemas" ] [ "HTTPValidationError" ] ;
515517 } ;
516518 } ;
517- /** @description Internal Server Error */
518- default : {
519- headers : {
520- [ name : string ] : unknown ;
521- } ;
522- content : {
523- "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
524- } ;
525- } ;
519+ default : components [ "responses" ] [ "DefaultErrorSchemaResponse" ] ;
526520 } ;
527521 } ;
528522 post_files : {
Original file line number Diff line number Diff line change @@ -89,7 +89,17 @@ export interface components {
8989 url : string ;
9090 } ;
9191 } ;
92- responses : never ;
92+ responses : {
93+ /** @description Unexpected error */
94+ DefaultErrorSchemaResponse : {
95+ headers : {
96+ [ name : string ] : unknown ;
97+ } ;
98+ content : {
99+ "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
100+ } ;
101+ } ;
102+ } ;
93103 parameters : {
94104 IdIn : string [ ] ;
95105 /** @example 2023-06-04 */
@@ -160,15 +170,7 @@ export interface operations {
160170 "application/json" : components [ "schemas" ] [ "HTTPValidationError" ] ;
161171 } ;
162172 } ;
163- /** @description Internal Server Error */
164- default : {
165- headers : {
166- [ name : string ] : unknown ;
167- } ;
168- content : {
169- "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
170- } ;
171- } ;
173+ default : components [ "responses" ] [ "DefaultErrorSchemaResponse" ] ;
172174 } ;
173175 } ;
174176 post_files : {
Original file line number Diff line number Diff line change @@ -89,7 +89,17 @@ export interface components {
8989 url : string ;
9090 } ;
9191 } ;
92- responses : never ;
92+ responses : {
93+ /** @description Unexpected error */
94+ DefaultErrorSchemaResponse : {
95+ headers : {
96+ [ name : string ] : unknown ;
97+ } ;
98+ content : {
99+ "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
100+ } ;
101+ } ;
102+ } ;
93103 parameters : {
94104 IdIn : string [ ] ;
95105 /** @example 2023-06-04 */
@@ -160,15 +170,7 @@ export interface operations {
160170 "application/json" : components [ "schemas" ] [ "HTTPValidationError" ] ;
161171 } ;
162172 } ;
163- /** @description Internal Server Error */
164- default : {
165- headers : {
166- [ name : string ] : unknown ;
167- } ;
168- content : {
169- "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
170- } ;
171- } ;
173+ default : components [ "responses" ] [ "DefaultErrorSchemaResponse" ] ;
172174 } ;
173175 } ;
174176 post_files : {
Original file line number Diff line number Diff line change @@ -126,7 +126,17 @@ export interface components {
126126 url : string ;
127127 } ;
128128 } ;
129- responses : never ;
129+ responses : {
130+ /** @description Unexpected error */
131+ DefaultErrorSchemaResponse : {
132+ headers : {
133+ [ name : string ] : unknown ;
134+ } ;
135+ content : {
136+ "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
137+ } ;
138+ } ;
139+ } ;
130140 parameters : {
131141 IdIn : string [ ] ;
132142 /** @example 2023-06-04 */
@@ -197,15 +207,7 @@ export interface operations {
197207 "application/json" : components [ "schemas" ] [ "HTTPValidationError" ] ;
198208 } ;
199209 } ;
200- /** @description Internal Server Error */
201- default : {
202- headers : {
203- [ name : string ] : unknown ;
204- } ;
205- content : {
206- "application/json" : components [ "schemas" ] [ "ErrorSchemaResponse" ] ;
207- } ;
208- } ;
210+ default : components [ "responses" ] [ "DefaultErrorSchemaResponse" ] ;
209211 } ;
210212 } ;
211213 post_files : {
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ export type OpenAPISchemaType = {
2424 } ;
2525 responses : {
2626 [ statusCode in number | 'default' ] : {
27- description : string ;
27+ $ref ?: string ;
28+ description ?: string ;
2829 content ?: {
2930 [ contentType : string ] :
3031 | {
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ export const getServices = (
6666 >
6767 > (
6868 ( acc , [ statusCode , response ] ) => {
69+ if ( response . $ref ) {
70+ response = resolveDocumentLocalRef (
71+ response . $ref ,
72+ openApiJson
73+ ) as typeof response ;
74+ }
75+
6976 const statusType =
7077 statusCode !== 'default' && // See "default" response https://swagger.io/docs/specification/describing-responses/#default
7178 Number ( statusCode ) < 400
Original file line number Diff line number Diff line change 120120 }
121121 },
122122 "default" : {
123- "description" : " Unexpected error" ,
124- "content" : {
125- "application/json" : {
126- "schema" : { "$ref" : " #/components/schemas/ErrorSchemaResponse" }
127- }
128- }
123+ "$ref" : " #/components/responses/DefaultErrorSchemaResponse"
129124 }
130125 },
131126 "security" : [{ "userToken" : [] }, { "partnerToken" : [] }]
493488 }
494489 },
495490 "default" : {
496- "description" : " Internal Server Error" ,
497- "content" : {
498- "application/json" : {
499- "schema" : { "$ref" : " #/components/schemas/ErrorSchemaResponse" }
500- }
501- }
491+ "$ref" : " #/components/responses/DefaultErrorSchemaResponse"
502492 }
503493 },
504494 "security" : [{ "HTTPBearer" : [] }]
881871 }
882872 }
883873 }
874+ },
875+ "responses" : {
876+ "DefaultErrorSchemaResponse" : {
877+ "description" : " Unexpected error" ,
878+ "content" : {
879+ "application/json" : {
880+ "schema" : { "$ref" : " #/components/schemas/ErrorSchemaResponse" }
881+ }
882+ }
883+ }
884884 }
885885 }
886886}
You can’t perform that action at this time.
0 commit comments