frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Auto-generate TypeScript client with types from backend's documented Swagger API

Open bnjmnt4n opened this issue 3 years ago • 6 comments

Description

Using https://github.com/acacode/swagger-typescript-api, a TypeScript-based client with types is generated from the cadet backend's swagger.json.

TODO:

  • [ ] Add documentation
    • Basic instructions
      • Copy swagger.json to src/commons/api/
      • Run yarn run update-cadet-api
  • [ ] Avoid typecasting
  • [ ] Ensure generated types are accurate
  • [ ] Switch from fetch to the new API globally

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [X] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update
  • [X] Code quality improvements

How to test

Run the test suite.

Checklist

  • [ ] I have tested this code
  • [ ] I have updated the documentation

bnjmnt4n avatar Apr 15 '21 09:04 bnjmnt4n

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 94db8bd
Status: ✅  Deploy successful!
Preview URL: https://db7968c8.cadet-frontend.pages.dev

View logs

Yes, yes, so much yes. This is probably the best thing that's happened in the frontend code-quality wise ever since it was written. Looking forward to seeing this merged :)

angelsl avatar Apr 15 '21 21:04 angelsl

Hmm, anyone looking after this PR? @bnjmnt4n ? There is enthusiastic support from @angelsl . But still in draft and currently with merge conflict...

martin-henz avatar Jun 10 '21 10:06 martin-henz

Sorry for the delays. I was planning to come back to it, and will take a look at it hopefully this weekend.

bnjmnt4n avatar Jun 10 '21 12:06 bnjmnt4n

Reviewing our open PRs and this one comes up again. @bnjmnt4n do you have time these days? There is/was enthusiastic support from @angelsl . But still in draft and currently with merge conflict...

martin-henz avatar Dec 16 '21 09:12 martin-henz

This will need quite a bit of time to properly convert all the places in the frontend that make requests to the backend. And we need to make sure the backend Swagger definitions are accurate as well (unfortunately Elixir is dynamically typed so it's not possible to generate Swagger definitions from type information...)

It'll be tedious but worth it.

angelsl avatar Dec 16 '21 09:12 angelsl