RI-7682 Tighten swagger decorators to align with FE consumption#5886
Merged
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
Code Coverage - Backend unit tests
Test suite run success3357 tests passing in 305 suites. Report generated by 🧪jest coverage report action from 90a0334 |
Contributor
Code Coverage - Integration Tests
|
Contributor
Code Coverage - Frontend unit tests
Test suite run success6781 tests passing in 786 suites. Report generated by 🧪jest coverage report action from 90a0334 |
valkirilov
previously approved these changes
May 12, 2026
Continuation of PR #5885. The import migration surfaced ~457 type-level shape gaps between the BE class declarations and the OpenAPI spec they generated. This PR closes most of them at the source rather than at every call site. BE swagger decorators - Add `enumName: 'X'` to 64 `@ApiProperty({ enum: X, ... })` sites so Nest emits each enum as a referenced `components/schemas/X` instead of inlining it as a string-literal union. @hey-api/openapi-ts then produces named TS enums in apiClient (43 enum schemas total). - Convert 61 `@ApiProperty` decorators to `@ApiPropertyOptional` where the underlying field is TS-optional (`name?:`), so the OpenAPI spec no longer marks them required. - Add `@ApiPropertyOptional` to the `eula` / `analytics` / `notifications` fields on `GetUserAgreementsResponse` that exist at runtime but had no decorator. Generator config - Flip `@hey-api/typescript` to `enums: 'typescript'` with `case: 'PascalCase'` so enum member names match BE source style for the majority of enums (e.g. `NodeRole.Primary`, `ResultsMode.Default`). FE factories - Convert `faker.date.past()` to `.toISOString()` in factories where the destination type is now `string` (api-client wire format) rather than `Date` (BE class). Left `DBInstance.factory.ts` alone — the FE `Instance` interface still uses `Date` locally. tsc delta (no CI gate, but observable locally): - main: 2498 errors - PR #5885 only: 2168 errors (−330, with 465 new shape-drift errors) - This PR on top: 2014 errors (−484 vs main, 300 new vs main) Net: ~155 fewer type-level findings than after PR #5885 alone. The remaining 300 are largely FE-local enum mirrors that nominally collide with the new apiClient enums (e.g. `RunQueryMode`, `TimezoneOption`) and FE state shapes that diverge from the wire shape — those want a separate per-domain cleanup pass. Refs RI-7682 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The decorator file exposes a wrapper `ApiRedisString(...)` that calls
`ApiProperty(...)` directly (not as a `@ApiProperty(...)` decorator),
which the previous unused-import sweep missed. Restoring the import
fixes the `dump-openapi` step in CI:
ReferenceError: ApiProperty is not defined
at ApiRedisString (redis-string-schema.decorator.ts:27:3)
Refs RI-7682
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…specs commandExecutionFactory now produces `createdAt` as an ISO string (to match api-client's wire shape). These specs were normalising the value with `.toISOString()` in their expected-output maps, which now throws because the value is already a string. Drop the `.toISOString()` call so the expected createdAt is the same value the factory emits — string in, string out. Refs RI-7682 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
261cc7a to
90a0334
Compare
valkirilov
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Continuation of #5885. The import migration there surfaced ~457 type-level shape gaps between the BE class declarations and the OpenAPI spec they generate. This PR closes most of them at the source rather than at every call site.
Base note: stacked on top of #5885 (
feature/RI-7682/consume-apiclient-types). After #5885 merges, GitHub will auto-retarget this PR's base tomain.BE swagger decorators
enumNameadded to 64@ApiProperty({ enum: X, ... })sites so Nest emits each enum as a referencedcomponents/schemas/Xinstead of inlining it as a string-literal union.@hey-api/openapi-tsthen produces named TS enums inapiClient(43 enum schemas total now, up from 3 in RI-7682 Consume auto-generated apiClient types in the UI #5885).@ApiProperty→@ApiPropertyOptionalfor 61 fields where the TS declaration isname?:but the swagger decorator was the required variant. Surfaced as ~80 of the FE regressions in RI-7682 Consume auto-generated apiClient types in the UI #5885 (Rdi.lastConnection,CommandExecutionResult.sizeLimitExceeded,CloudUserAccount.capiKey/capiSecret, etc.).@ApiPropertyOptionalforeula/analytics/notificationsonGetUserAgreementsResponse. These exist at runtime but had no decorator at all, so the spec didn't declare them.Generator config
@hey-api/typescriptis nowenums: 'typescript'withcase: 'PascalCase', so member names match the BE source style for the majority of enums (NodeRole.Primary,ResultsMode.Default, etc.). Aligned with what #5885 chose.FE factories
Three mock factories that fed
faker.date.past()(aDate) into fields whose wire format isstring(ISO timestamp) now.toISOString()the value.DBInstance.factory.tsis left alone — the FEInstanceinterface keepslastConnection: Datelocally for state, distinct from the wire shape.Testing
yarn lintpasses (UI + API).yarn generate:api-clientsucceeds — spec dump boots the AppModule, so any malformed decorator would fail here.tsc -p tsconfig.json(no CI gate, but observable locally):main: 2498 errorsThe remaining 300 are largely FE-local enum mirrors that nominally collide with the new
apiClientenums (e.g.RunQueryMode,TimezoneOption,Vote,CommandExecutionStatusare declared both inapiClientandslices/interfaces/*), plus FE state shapes that diverge from the wire shape (e.g.IKeyPropTypesrequires fields that became optional onGetKeyInfoResponse). Those want a focused per-domain cleanup pass — out of scope here.Refs RI-7682
Note
Medium Risk
Broad updates to Swagger metadata (optional fields and enum schema naming) can change the generated OpenAPI spec and thus the UI’s generated
apiClienttypes, but runtime behavior should be unchanged.Overview
Tightens the generated OpenAPI contract by adding
enumNameto many Swagger-decorated enums so they are emitted as referenced schemas and become named TypeScript enums in the generatedapiClient(with PascalCase member casing preserved).Fixes mismatches where properties typed as optional in TS were still marked required in Swagger by switching many
@ApiPropertyannotations to@ApiPropertyOptional, and adds missing optional Swagger docs for user agreement flags.Updates UI mocks/tests to treat
createdAt/lastConnectionas ISO strings (notDateobjects) to match the wire/API-client types.Reviewed by Cursor Bugbot for commit 90a0334. Bugbot is set up for automated code reviews on this repo. Configure here.