Skip to content

RI-7682 Tighten swagger decorators to align with FE consumption#5886

Merged
KrumTy merged 3 commits into
mainfrom
feature/RI-7682/swagger-tightening
May 12, 2026
Merged

RI-7682 Tighten swagger decorators to align with FE consumption#5886
KrumTy merged 3 commits into
mainfrom
feature/RI-7682/swagger-tightening

Conversation

@KrumTy
Copy link
Copy Markdown
Contributor

@KrumTy KrumTy commented May 11, 2026

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 to main.

BE swagger decorators

  • enumName added 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 now, up from 3 in RI-7682 Consume auto-generated apiClient types in the UI #5885).
  • @ApiProperty@ApiPropertyOptional for 61 fields where the TS declaration is name?: 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.).
  • Add missing @ApiPropertyOptional for eula / analytics / notifications on GetUserAgreementsResponse. These exist at runtime but had no decorator at all, so the spec didn't declare them.

Generator config

@hey-api/typescript is now enums: 'typescript' with case: '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() (a Date) into fields whose wire format is string (ISO timestamp) now .toISOString() the value. DBInstance.factory.ts is left alone — the FE Instance interface keeps lastConnection: Date locally for state, distinct from the wire shape.

Testing

The remaining 300 are largely FE-local enum mirrors that nominally collide with the new apiClient enums (e.g. RunQueryMode, TimezoneOption, Vote, CommandExecutionStatus are declared both in apiClient and slices/interfaces/*), plus FE state shapes that diverge from the wire shape (e.g. IKeyPropTypes requires fields that became optional on GetKeyInfoResponse). 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 apiClient types, but runtime behavior should be unchanged.

Overview
Tightens the generated OpenAPI contract by adding enumName to many Swagger-decorated enums so they are emitted as referenced schemas and become named TypeScript enums in the generated apiClient (with PascalCase member casing preserved).

Fixes mismatches where properties typed as optional in TS were still marked required in Swagger by switching many @ApiProperty annotations to @ApiPropertyOptional, and adds missing optional Swagger docs for user agreement flags.

Updates UI mocks/tests to treat createdAt/lastConnection as ISO strings (not Date objects) 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.

@KrumTy KrumTy added the AI-Made label May 11, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 11, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 92.57% 15407/16644
🟡 Branches 74.47% 4812/6462
🟢 Functions 86.54% 2391/2763
🟢 Lines 92.39% 14723/15936

Test suite run success

3357 tests passing in 305 suites.

Report generated by 🧪jest coverage report action from 90a0334

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 79.81% 17436/21846
🟡 Branches 62.26% 7970/12801
🟡 Functions 68.55% 2418/3527
🟡 Lines 79.37% 16393/20652

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.65% 24215/29299
🟡 Branches 67.85% 10195/15026
🟡 Functions 77.76% 6531/8399
🟢 Lines 83.12% 23668/28475

Test suite run success

6781 tests passing in 786 suites.

Report generated by 🧪jest coverage report action from 90a0334

@KrumTy KrumTy marked this pull request as ready for review May 11, 2026 08:57
@KrumTy KrumTy requested a review from a team as a code owner May 11, 2026 08:57
valkirilov
valkirilov previously approved these changes May 12, 2026
Base automatically changed from feature/RI-7682/consume-apiclient-types to main May 12, 2026 13:08
@KrumTy KrumTy dismissed valkirilov’s stale review May 12, 2026 13:08

The base branch was changed.

KrumTy and others added 3 commits May 12, 2026 16:11
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>
@KrumTy KrumTy force-pushed the feature/RI-7682/swagger-tightening branch from 261cc7a to 90a0334 Compare May 12, 2026 13:12
@KrumTy KrumTy requested a review from valkirilov May 12, 2026 13:13
@KrumTy KrumTy merged commit 6462b42 into main May 12, 2026
71 of 73 checks passed
@KrumTy KrumTy deleted the feature/RI-7682/swagger-tightening branch May 12, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants