Skip to content

swagger-typescript-api fails to fetch some file information or remote #1876

Open
@FDiskas

Description

@FDiskas

Describe the bug

ℹ try to get swagger by URL "https://fakerestapi.azurewebsites.net/swagger/v1/swagger.yaml" 8:23:21 PM

ERROR error while fetching data from URL "https://fakerestapi.azurewebsites.net/swagger/v1/swagger.yaml" fetch failed 8:23:21 PM

at <anonymous> (node:internal/deps/undici/undici:97:352419)
at <anonymous> (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:28909)

[cause]: other side closed

  at new UndiciError (node:internal/deps/undici/undici:97:402)
  at new SocketError (node:internal/deps/undici/undici:97:3383)
  at TLSSocket.<anonymous> (node:internal/deps/undici/undici:97:236673)
  at TLSSocket.emit (node:events:30:11150)
  at endReadableNT (node:internal/streams/readable:230:10631)
  at processTicksAndRejections (node:internal/process/task_queues:196:1067)
  at <anonymous> (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:295436)
  at _0x379a45 (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:295517)
  at _0x5a6932 (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:544416)
  at <anonymous> (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:544200)

ERROR Cannot create property 'info' on string 'error while fetching data from URL "https://fakerestapi.azurewebsites.net/swagger/v1/swagger.yaml"' 8:23:21 PM

at eval (node_modules/swagger-typescript-api/dist/src-BzzyC03Z.js:2339:16)
at https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:27327
at new Promise (<anonymous>)
at new Promise (https://vitejsvitebzr4utiz-2ovd.w-credentialless-staticblitz.com/blitz.4d9fd228.js:31:27262)
at SwaggerSchemaResolver.convertSwaggerObject (node_modules/swagger-typescript-api/dist/src-BzzyC03Z.js:2337:10)
at SwaggerSchemaResolver.create (node_modules/swagger-typescript-api/dist/src-BzzyC03Z.js:2334:21)
at async CodeGenProcess.start (node_modules/swagger-typescript-api/dist/src-BzzyC03Z.js:2873:19)
at async Module.generateApi (node_modules/swagger-typescript-api/dist/src-BzzyC03Z.js:3084:9)
at async Object.run (node_modules/swagger-typescript-api/dist/cli.js:284:3)
at async runCommand (node_modules/citty/dist/index.mjs:337:16) 

Link to the blitz that caused the error

https://stackblitz.com/edit/vitejs-vite-bzr4utiz?file=src%2FApp.tsx,package.json,src%2Fgen%2Ffakeapi.yaml,.gitignore&terminal=dev

Steps to reproduce

  1. npm i swagger-typescript-api
  2. npm pkg set scripts.foo="swagger-typescript-api generate -p https://fakerestapi.azurewebsites.net/swagger/v1/swagger.json -o ./src/gen/fake --clean-output --modular --extract-enums"
  3. npm run foo

Expected behavior

the tool should be able to download remote file and parse it.
This tools also supports local files - same error

Parity with Local

Screenshots

Image

Platform

Browser name  = Chrome
Full version  = 136.0.0.0
Major version = 136
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 148061101,
  "usedJSHeapSize": 144672477,
  "jsHeapSizeLimit": 4294705152
}
Hash = 4d9fd228

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions