diff --git a/__tests__/resources/example-pet-api.openapi.yml b/__tests__/resources/example-pet-api.openapi.yml index 90c8f0b..413f82b 100644 --- a/__tests__/resources/example-pet-api.openapi.yml +++ b/__tests__/resources/example-pet-api.openapi.yml @@ -19,6 +19,8 @@ paths: responses: '200': description: List of pets in database + default: + description: unexpected error parameters: - name: limit in: query diff --git a/src/typegen/typegen.test.ts b/src/typegen/typegen.test.ts index 6f601bf..17f0038 100644 --- a/src/typegen/typegen.test.ts +++ b/src/typegen/typegen.test.ts @@ -62,7 +62,7 @@ describe('generateTypesForDocument', () => { }); test('types responses', () => { - expect(clientOperationTypes).toMatch(`OperationResponse`); + expect(clientOperationTypes).toMatch(`OperationResponse`); expect(clientOperationTypes).toMatch('OperationResponse'); expect(clientOperationTypes).toMatch('OperationResponse'); expect(clientOperationTypes).toMatch('OperationResponse'); diff --git a/src/typegen/typegen.ts b/src/typegen/typegen.ts index 7c0159c..05a6968 100644 --- a/src/typegen/typegen.ts +++ b/src/typegen/typegen.ts @@ -217,7 +217,7 @@ function generateMethodForClientOperation( // return type const responseTypePaths = _.chain(exportTypes) - .filter(({ schemaRef }) => schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/2`)) + .filter(({ schemaRef }) => schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/2`) || schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/default`)) .map(({ path }) => path) .value(); const responseType = !_.isEmpty(responseTypePaths) ? responseTypePaths.join(' | ') : 'any';