openapi-codegen-ts icon indicating copy to clipboard operation
openapi-codegen-ts copied to clipboard

`Buffer` type breaks generated SDKs

Open balanza opened this issue 3 years ago • 1 comments

Operations which produce octet/stream responses will be resolved into generated definitions using Buffer as defined in https://github.com/pagopa/openapi-codegen-ts/pull/293

This breaks the build of SDK packages as Buffer is not a native Typescript type

Example

swagger: '2.0'
info:
  version: 1.0.0
  title: API
host: localhost
basePath: /api/v1
schemes:
  - https
paths:
  /mypath:
    get:
      summary: An endpoint
      produces:
        - application/octet-stream
      responses:
        '200':
          description: Success
          schema:
            format: binary
            type: string
        '400':
          description: Bad Request
        '500':
          description: Internal Server Error
requestTypes.ts:2047:8 - error TS4016: Type parameter 'A0' of exported function has or is using private name 'Buffer'.

balanza avatar Jan 04 '23 10:01 balanza

The easier solution would be to add @types/node as a dev dependency of the generated package. I have some concerns:

  1. Should we use a specific version of Node?
  2. Is it correct to reference Node? SDKs are meant to be used both in a Node application and in the browser.

balanza avatar Jan 04 '23 10:01 balanza