Update type generation command to use heyapi#7920
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Dependency Review✅ No vulnerabilities found.Scanned FilesNone |
There was a problem hiding this comment.
Code Review
This PR migrates the openapi:generate and openapi:generate-dictionary npm scripts from the old openapi CLI (inline flags) to the new openapi-ts CLI (@hey-api/openapi-ts) backed by dedicated config files. The change is clean and the config files contain meaningful customization (schema patches, enum varname remapping, per-symbol file splitting). A couple of things worth a look:
Config API inconsistency (notable)
openapi-ts-dictionary.config.ts uses a types top-level key for enum and casing settings, while openapi-ts-api.config.ts uses the plugins array with @hey-api/typescript. At ^0.88.2 the plugins-based API is the current one; the types key appears to be from an earlier version and may be silently ignored, meaning the enum/casing settings in the dictionary config might not actually apply. This is flagged inline on line 30.
Prettier scope change
The old openapi:generate command ran prettier --write . (the whole project) after generation. The new approach scopes formatting to the output path via format: "prettier" in the config. This is almost certainly better, but worth verifying that no other files were relying on that trailing prettier --write . to stay formatted during the codegen workflow.
Minor observations in openapi-ts-api.config.ts
- The file has
/* eslint-disable no-param-reassign */at the top, making the// eslint-disable-next-line no-param-reassigninline comments on lines 20 and 29 redundant. - Several
patch.schemashandlers use(schema: any)— this is a pragmatic workaround but worth noting in case the library exposes better types for these patch callbacks in the future. getFilePathreturnsundefinedto skip endpoint-specific types and route each named symbol tomodels/<Name>. This is a meaningful structural change from the old flat output; confirming that all existing imports from./src/types/apistill resolve correctly after regeneration would be a good sanity check.
Overall
The migration looks reasonable. The main actionable item is verifying or fixing the dictionary config's API version to use plugins for consistency with the main config.
🔬 Codegraph: unavailable
💡 Write /code-review in a comment to re-run this review.
| "lint-staged:fix": "lint-staged --diff=main", | ||
| "openapi:generate": "openapi --input http://localhost:8080/openapi.json --output ./src/types/api --exportCore false --exportServices false --indent 2 && prettier --write .", | ||
| "openapi:generate-dictionary": "openapi --input http://localhost:8081/openapi.json --output ./src/types/dictionary-api --exportCore false --exportServices false --indent 2", | ||
| "openapi:generate": "openapi-ts --file openapi-ts-api.config.ts", |
There was a problem hiding this comment.
clients/admin-ui/package.json:29
The old command ran prettier --write . after code generation. The new config handles formatting via format: "prettier" in openapi-ts-api.config.ts, so that's covered for the API types. Just worth confirming the prettier formatting output is equivalent — particularly that the same files are reformatted (the old command targeted ., the new one targets only the generated output path).
| "openapi:generate": "openapi --input http://localhost:8080/openapi.json --output ./src/types/api --exportCore false --exportServices false --indent 2 && prettier --write .", | ||
| "openapi:generate-dictionary": "openapi --input http://localhost:8081/openapi.json --output ./src/types/dictionary-api --exportCore false --exportServices false --indent 2", | ||
| "openapi:generate": "openapi-ts --file openapi-ts-api.config.ts", | ||
| "openapi:generate-dictionary": "openapi-ts --file openapi-ts-dictionary.config.ts", |
There was a problem hiding this comment.
clients/admin-ui/package.json:30
openapi-ts-dictionary.config.ts uses a types top-level key (types.enums, types.identifierCase) while openapi-ts-api.config.ts uses the plugins array (@hey-api/typescript with enums and case). These look like different API versions of @hey-api/openapi-ts. With the installed version ^0.88.2, the types key may be silently ignored or produce a deprecation warning. Consider aligning the dictionary config to use the same plugins-based API as the main config to ensure the enum generation settings actually take effect.
Ticket ENG-1859
Description Of Changes
Update openapi:generate command in admin-ui to use the new heyapi generation library. The command update was mistakenly reverted on the original PR #7757
Code Changes
Steps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works