Skip to content

feat: add tsoa for API type control and documentation#1501

Open
Andreybest wants to merge 26 commits into
finos:mainfrom
Andreybest:1430-api-checking-docs
Open

feat: add tsoa for API type control and documentation#1501
Andreybest wants to merge 26 commits into
finos:mainfrom
Andreybest:1430-api-checking-docs

Conversation

@Andreybest

Copy link
Copy Markdown
Contributor

Resolves #1430.

Add tsoa for endpoint type checking and generation of OpenAPI documentation. Generates swagger.json to /dist folder.
All tests for endpoints that were present, passes (with minor changes), all logic is preserved.

Caveats:

  1. tsoa checks for field presence, but does not check if string in field is empty, thus should be checked manually (or I've missed something in configuration). For example: POST api/v1/push/{id}/reject (rejectPush), if empty or whitespaces provided, will not check for it, thus old logic for theck with .trim() is left.
  2. tsoa has a configuration field noImplicitAdditionalProperties, that allows to change behavior of endpoints for rejecting of excess fields. Currently set to ignore due to POST api/v1/repo (createRepo), this endpoint passes body to a db.createRepo(body), and inner type expects additionalProperties that are passed to a row in a DB. Question: is this expected or not? If not, maybe we should enable more strict mode on noImplicitAdditionalProperties? :)

@Andreybest Andreybest requested a review from a team as a code owner April 10, 2026 12:54
@netlify

netlify Bot commented Apr 10, 2026

Copy link
Copy Markdown

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit 7ba58da
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6a3064c15dd04b000870ffee
😎 Deploy Preview https://deploy-preview-1501.git-proxy.preview.finos.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Andreybest Andreybest requested a review from jescalada April 10, 2026 12:54

@jescalada jescalada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, @Andreybest! 🚀

Things are looking good so far, just a few things to mention other than the code comments:

  • It'd be great to have screenshots of the generated OpenAPI spec to see if things are working as we hoped
  • I noticed a duplicate interface (AttestationAnswer) and am wondering if there aren't other interfaces that can be reused or combined into one
  • Test coverage seems to go down somewhat (-1.5%), we should improve coverage on any code additions such as proxyStore.ts, etc.

We might need another review since the changes are quite large @finos/git-proxy-maintainers

Comment thread package.json
Comment thread src/app.ts
Comment thread src/service/authentication.ts
Comment thread src/service/controllers/AuthController.ts Outdated
Comment thread src/service/controllers/AuthController.ts Outdated
Comment thread src/service/controllers/RepoController.ts
Comment thread src/service/interfaces/common.interfaces.ts
Comment thread test/services/routes/auth.test.ts
Comment thread test/services/routes/users.test.ts Outdated
Comment thread tsoa.json
@kriswest

Copy link
Copy Markdown
Contributor

@jescalada and @Andreybest There is a docusaurus plugin for rendering OpenAPI docs at:

https://docusaurus-openapi.tryingpan.dev/
https://github.com/PaloAltoNetworks/docusaurus-openapi-docs

Whereas in the FDC3 website we use a very simple static page and the Redoc lib to render the same: https://github.com/finos/FDC3/blob/main/website/src/pages/schemas/next/app-directory.html

Note that you have to link to this as an external link or docusaurus will return a 404 when navigating within the site:

https://github.com/finos/FDC3/blob/ffea3be0735bdd7a72ffba5473addfe49535833e/website/docs/app-directory/spec.md?plain=1#L7-L13

@Andreybest

Copy link
Copy Markdown
Contributor Author

Thank you for the review @jescalada !
Can you please review it again? Applied changes to most of your comments :)

  1. Screenshot of swagger
image 2. Duplicate removed, quickly checked, should be no more repetiotions (but not sure) 3. Don't see a message from code cov bot on this matter, can you please show me where I can find a code coverage stats?

@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. None was changed, checked up to commit 6981427c50a5e5ccd3e91a2d4229b27135f8dcc3

Comment thread package.json Outdated
Co-authored-by: Fabio Vincenzi <93596376+fabiovincenzi@users.noreply.github.com>
Signed-off-by: Andrew <andrey255@live.com>
@Andreybest

Copy link
Copy Markdown
Contributor Author

Thanks for change @fabiovincenzi ! Added your suggested change.

@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. None was changed, checked up to commit: ad58c5a47f64b6380da1ce1d7f6556c17e7e9efc

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.23940% with 292 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.38%. Comparing base (656d3f5) to head (7ba58da).

Files with missing lines Patch % Lines
src/service/generatedRoutes.ts 86.02% 178 Missing ⚠️
src/service/controllers/AuthController.ts 75.25% 45 Missing and 3 partials ⚠️
src/service/controllers/PushController.ts 90.85% 15 Missing and 1 partial ⚠️
src/service/authentication.ts 77.35% 10 Missing and 2 partials ⚠️
src/service/index.ts 60.86% 9 Missing ⚠️
src/service/controllers/RepoController.ts 95.78% 7 Missing and 1 partial ⚠️
src/service/controllers/UserController.ts 94.77% 8 Missing ⚠️
src/service/controllers/HomeController.ts 53.84% 6 Missing ⚠️
src/service/proxyStore.ts 70.00% 3 Missing ⚠️
src/app.ts 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1501      +/-   ##
==========================================
- Coverage   85.51%   85.38%   -0.13%     
==========================================
  Files          83       85       +2     
  Lines        7877     9137    +1260     
  Branches     1312     1327      +15     
==========================================
+ Hits         6736     7802    +1066     
- Misses       1114     1305     +191     
- Partials       27       30       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@re-vlad re-vlad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just small non critical change requested

Comment thread tsoa.json Outdated
Comment thread src/service/index.ts
@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. Only change with addition of https server, which required to change test files for https, would appreciate check on this.

Checked up to commit: 4c6e8d47d9189ee016d6f6a59adbd2f013c0666f

@Andreybest Andreybest requested a review from kriswest May 18, 2026 02:08

@jescalada jescalada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andreybest LGTM, just needs fixes for the failing tests!

It seems this commit (a23b7eb) breaks them - I'm wondering if it's due to the throw-on-error option we added, or the tweaks to the repo tests themselves 🤔

@Andreybest

Copy link
Copy Markdown
Contributor Author

Thank you @jescalada! Sorry for not replying on previous review.
On tests - fixed, reason - no idea, but the change is minimal - users for creation of new repo is now optional to be aligned with tests. In the code for interaction with db it is replaced with empty arrays anyway, so should work as expected :)

@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. None was changed, checked up to commit: ffd6937419b1d3de718c60ec26604f9f7541fffa

fabiovincenzi and others added 5 commits June 4, 2026 05:47
* feat: generate API reference docs from OpenAPI spec
* fix: escape backslashes before pipes in Markdown table descriptions
Signed-off-by: Juan Escalada <97265671+jescalada@users.noreply.github.com>
@jescalada jescalada force-pushed the 1430-api-checking-docs branch from a5df2cb to b2d07a6 Compare June 5, 2026 09:12
@jescalada

Copy link
Copy Markdown
Contributor

Just pushed fixes for the E2E (Docker) and Cypress tests. The throw flag is indeed causing the test failures due to how strict it is with unused/extra params.

Meanwhile the Dependency error is coming from critical vulnerabilities in our devDependencies (vitest, nyc). Upgrading breaks our tests, so I'll find fixes for these and report back 👍🏼

@jescalada

Copy link
Copy Markdown
Contributor

@kriswest I think this can be reviewed again since Dependency Review isn't a required check. I'll do the Vitest upgrade in a separate PR!

@Andreybest

Copy link
Copy Markdown
Contributor Author

Hey @jescalada! Thanks for the fixes! Merged latest main to PR and added suggestion from @fabiovincenzi on pre-commit generation of web docs (just like generatedRoutes being automatically generated on commit).
Please let me know if any changes are needed.

@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. On main new feature for getting params from config for server configuration was added to auth.ts route of old express api, moved logic to Auth controller, checked up to commit: 6e657167273404f4c2d668f9fd82f28045453058

Comment thread package.json
"start": "concurrently \"npm run server\" \"npm run client\"",
"build": "npm run generate-config-types && npm run build-ui && npm run build-ts",
"build-ts": "tsc --project tsconfig.publish.json && node scripts/fix-shebang.js",
"build-ts": "npm run build-tsoa && tsc --project tsconfig.publish.json && node scripts/fix-shebang.js",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you possibly need to add a run of the format script here as the generated code fails linting, but can be autofixed - which would stop this PR (and future ones) failing the linting check.

Alternatively see how generate-config-types runs prettier on a specific file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need to format generated files, I've actually added generatedRoutes.ts to .prettierIgnore, but it was not used, now it is fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not bothered either way tbh, as long as it passes the check. Other projects I work on apply automated fixes to generated files, and it occasionally squeezes out variations between different versions of the code generation dependency - but then can also introduce differences in PRs if the formatter wasn't run for some reason.

@kriswest

Copy link
Copy Markdown
Contributor

@Andreybest can you resolve conflicts and deal with the application of prettier to the generated files (to stop the linting check failing - see #1501 (comment)). After that this should be mergable!

@kriswest kriswest linked an issue Jun 15, 2026 that may be closed by this pull request
@Andreybest

Copy link
Copy Markdown
Contributor Author

Checked all commits on main branch for new changes to logic for endpoints. On main new ssh routes were added, and code for routes and tests were aligned with TSOA, checked up to commit: 656d3f5395c855834490e30b0db8b78411c27465

@Andreybest

Copy link
Copy Markdown
Contributor Author

@kriswest, conflicts resolved, new features alligned with this PR. On your comment - made a solution, please approve it, and if this works - lets go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render generated swagger.json for API documentation Improve API types and documentation

5 participants