swagger-api / swagger-api/swagger-codegen

Change superagent for the fetch api?

Open
#10,975 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/swagger-api/swagger-codegen/blob/068b1ebcb7b04a48ad38f1cadd24bb3810c9f1ab/modules/swagger-codegen/src/main/resources/Javascript/es6/ApiClient.mustache#L2-L3

Reason for switching
  • superagent use xhr instead of fetch and therefor don't work in service worker
    • fetch also has streaming support (unlike xhr)
  • Deno and Browser have fetch built in so no extra dependency, for node you could import eg node-fetch
    • there is a hot topic in bringing in the fetch api or similar functionality into node
  • fewer dependencies -> more lightweight
  • querystring is legacy
    • The URLsearchParam uses a more selective and fine grained approach to selecting encoded characters than that used by the Legacy API.
    • querystring.parse is depricated since v11
    • URLSearchParams is available in more environments without the need of any dependencies
    • querystring will mix the value between string and arrays giving you an inconsistent api

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/swagger-codegen/src/main/resources/Javascript/es6/ApiClient.mustache at lines 2-3 and inspect how the generated client uses superagent and querystring. Compare the required browser, service-worker, Deno, and Node environments with the proposed Fetch and URLSearchParams APIs. Done means the generated JavaScript client no longer depends on the named legacy components while retaining its existing request behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, web-dev
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.