acacode / acacode/swagger-typescript-api

Response data and error is null when using --extract-response-body

Đang mở
#652 4 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
4.1k
Fork
436
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

FWIW, I'm using this Swagger spec to generate an API: https://esi.evetech.net/latest/swagger.json

I then use the following command to generate the API:

```
swagger-typescript-api \
-p https://esi.evetech.net/latest/swagger.json \
-o src/app/api/esi \
--route-types \
--responses \
--extract-enums \
--extract-request-params \
--extract-request-body \
--extract-response-body \
--extract-response-error \
--modular \
--sort-types \
--sort-routes
```

Whenever I try to use `--extract-response-body`, I'm not ever able to access the data attribute. I have confirmed that I'm getting valid data back from `await response.json()`.

```ts
import { Api } from './api'

const api = new Api()

const response = await api.getContractsCharacterIdContracts({ ... })

// These don't work; both always null
// if (response.error) return
// const data = response.data

// This works fine
if (!response.ok) return
const data = await response.data()
```

It's only when I remove the `--extract-response-body` that I'm able to access the `data` and `error` attributes again.

Anything I'm doing wrong or is there something else going on?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.