|
139 | 139 | ? `zValidator('json', ${verbOption.operationName}Body),\n`
|
140 | 140 | : ''
|
141 | 141 | }${
|
142 |
| - verbOption.response.contentTypes.length === 1 && |
143 |
| - verbOption.response.contentTypes[0] === 'application/json' |
| 142 | + !!verbOption.response.originalSchema?.['200']?.content?.['application/json'] |
144 | 143 | ? `zValidator('response', ${verbOption.operationName}Response),\n`
|
145 | 144 | : ''
|
146 | 145 | }(c: ${contextTypeName}) => {
|
@@ -169,8 +168,7 @@ const getZvalidatorImports = (verbOption: GeneratorVerbOptions) => {
|
169 | 168 | }
|
170 | 169 |
|
171 | 170 | if (
|
172 |
| - verbOption.response.contentTypes.length === 1 && |
173 |
| - verbOption.response.contentTypes[0] === 'application/json' |
| 171 | + !!verbOption.response.originalSchema?.['200']?.content?.['application/json'] |
174 | 172 | ) {
|
175 | 173 | imports.push(`${verbOption.operationName}Response`);
|
176 | 174 | }
|
@@ -201,17 +199,14 @@ const getHandlerFix = ({
|
201 | 199 | const getVerbOptionGroupByTag = (
|
202 | 200 | verbOptions: Record<string, GeneratorVerbOptions>,
|
203 | 201 | ) => {
|
204 |
| - return Object.values(verbOptions).reduce( |
205 |
| - (acc, value) => { |
206 |
| - const tag = value.tags[0]; |
207 |
| - if (!acc[tag]) { |
208 |
| - acc[tag] = []; |
209 |
| - } |
210 |
| - acc[tag].push(value); |
211 |
| - return acc; |
212 |
| - }, |
213 |
| - {} as Record<string, GeneratorVerbOptions[]>, |
214 |
| - ); |
| 202 | + return Object.values(verbOptions).reduce((acc, value) => { |
| 203 | + const tag = value.tags[0]; |
| 204 | + if (!acc[tag]) { |
| 205 | + acc[tag] = []; |
| 206 | + } |
| 207 | + acc[tag].push(value); |
| 208 | + return acc; |
| 209 | + }, {} as Record<string, GeneratorVerbOptions[]>); |
215 | 210 | };
|
216 | 211 |
|
217 | 212 | const generateHandlers = async (
|
|
0 commit comments