RI-7682 Strengthen API public swagger docs and setup a postinstall script to autogenerate types for clients#5863
Conversation
Add tooling to auto-generate a typescript-axios client from the NestJS Swagger spec on yarn install. The spec and the generated client are treated as ephemeral build artifacts (gitignored), so the BE Swagger decorators remain the single source of truth. - Pin openapi-generator-cli to 7.14.0 via openapitools.json - Add dump-openapi.ts to extract the spec without an HTTP listener - Wire postinstall hook to regenerate the client on every install - Port ApiRedisString decorator for Buffer/RedisString wire format - Lint guard against new apiSrc/* and src/* imports from the UI References: #RI-7682
Fix 7 schema/path issues so the generator runs without
--skip-validate-spec:
- rdi-statistics: register union members (Table/Blocks/Info sections)
as top-level schemas via @ApiExtraModels + getSchemaPath
- vector-set DTOs: drop redundant isArray on number[] fields that
produced nested arrays in the spec
- bulk-actions and database-analysis controllers: declare the
{dbInstance} path parameter via @ApiRedisParams
Refs RI-7682
Add @ApiProperty/@ApiPropertyOptional to all fields on the Notification class so the generated client surfaces a real Notification interface and types NotificationsDto.notifications as Array<Notification> (was Array<object>). Refs RI-7682
Two response-type bugs caused the generated client to expose the wrong shapes for two database endpoints: - bulkDeleteDatabaseInstance declared DeleteDatabasesDto (the request body shape) but actually returns DeleteDatabasesResponse. - exportConnections returns ExportDatabase[] but the swagger metadata was missing isArray: true, so it appeared as a single object in the spec. Fix the @apiendpoint responses metadata to match the actual return types. The generated client now exposes AxiosPromise<DeleteDatabasesResponse> and AxiosPromise<Array<ExportDatabase>>. Refs RI-7682
Adopt @ApiRedisString for RedisString/Buffer fields and add response-type decorators on keys.controller endpoints so the generated TS client emits proper interfaces and array-typed responses. Refs RI-7682
Refs RI-7682
Apply targeted improvements from PR #4725: - list endpoint: correct description and array response type - update endpoint: correct description (analysis vs instance) - get/update endpoints: declare :id path param - models: mark NspSummary arrays with isArray, switch Key.name and NspSummary.nsp to ApiRedisString to model the wire format dbInstance path param remains declared via the class-level ApiRedisParams() introduced in the strict-validation commit. Refs RI-7682
- drop unused ApiPropertyOptional/ApiProperty imports left over after switching to ApiRedisString - prettier formatting in cloud-auth-request-info, cloud-auth-response, and rdi-statistics Refs RI-7682
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
Code Coverage - Frontend unit tests
Test suite run success6775 tests passing in 786 suites. Report generated by 🧪jest coverage report action from 2f08733 |
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
Code Coverage - Backend unit tests
Test suite run success3357 tests passing in 305 suites. Report generated by 🧪jest coverage report action from 2f08733 |
Code Coverage - Integration Tests
|
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
| @@ -0,0 +1,27 @@ | |||
| #!/usr/bin/env node | |||
There was a problem hiding this comment.
nit: I see the dump scripts live inside the API, but this API client, which should be used by the UI, is placed here on the root level. Is this intentional, or can we move it one level deeper, inside redisinisght/ui?
There was a problem hiding this comment.
The auto generated client is intentionally outside ui and api. We will have better control over it if it's not tied to the ui. E.g. in future we might use it in VSCode as well or publish it as a package even
There was a problem hiding this comment.
So basically, it will be a "shared package" after all - just not manually created (as @ArtemHoruzhenko asked), but automatically generated.
There was a problem hiding this comment.
"shared" as in all API consumers can reuse it, yes
and autogenerated based on API swagger docs, yes
| // RI-7682: discourage new BE -> FE coupling. Existing imports are still allowed | ||
| // (warn-only) until per-domain migration replaces them with `apiClient/*`. | ||
| // Flips to 'error' once Phase 2 is complete. | ||
| 'no-restricted-imports': [ |
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c6c8af9. Configure here.
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
❌ Jit Scanner failed - Our team is investigatingJit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions. 💡 Need to bypass this check? Comment |
|
@sera bypass |
|
@KrumTy @valkirilov feedback on @hey-api would be welcome as you use it more! |

What
Phase 1 of decoupling the UI from the API codebase (RI-7682).
typescript-axiosclient generation pipeline (yarn generate:api-client), regenerated onpostinstalland gitignored.@nestjs/swaggerso the generated client emits real types instead ofany/void. Strict spec validation is enabled.redisinsight/api-client/and is exposed to UI / Storybook / Jest via theapiClientpath alias.apiSrc/*imports from the UI, pointing devs atapiClient/*(RI-7682).No UI imports are migrated in this PR — that follows per-domain in Phase 2.
Testing
yarn install(oryarn generate:api-client) producesredisinsight/api-client/with no validation errors.Note
Medium Risk
Adds a new OpenAPI spec dump + client generation step that runs on API
postinstall, which can affect install/build workflows and CI caching. Broad Swagger annotation changes across many endpoints may subtly alter the published API schema and generated client types.Overview
Adds a generated OpenAPI TypeScript client pipeline: the API now dumps
openapi.jsonvia a lightweight Nest bootstrap (dump-openapi.ts) and runs@hey-api/openapi-tsto outputredisinsight/api-client/(gitignored), exposed via the newapiClient/*alias in TS, Vite/Storybook, and Jest.Strengthens Swagger/OpenAPI typing across multiple API modules by standardizing Redis string schemas (
ApiRedisString), fixing/adding response metadata (@ApiOkResponse, correctisArray/type), and improving union/discriminator schemas (e.g., REJSON, RDI statistics). Also adds a warn-only ESLintno-restricted-importsrule to discourage new UI imports fromapiSrc/*in favor ofapiClient/*, and updates test Docker installs to skip client generation when needed (SKIP_API_CLIENT_GEN=1).Reviewed by Cursor Bugbot for commit 2f08733. Bugbot is set up for automated code reviews on this repo. Configure here.