-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feat(typescript-axios): add useErasableSyntax option for erasableSynt… #22933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(typescript-axios): add useErasableSyntax option for erasableSynt… #22933
Conversation
…axOnly compiler support - Add useErasableSyntax option to TypeScriptAxiosClientCodegen (default: false) - Update baseApi.mustache to generate erasable syntax when enabled - Fix semicolons in configuration.mustache for consistency - Add comprehensive test coverage (4 new tests, all passing) - Regenerate all typescript-axios samples with semicolon fixes This change enables support for TypeScript's 'erasableSyntaxOnly' compiler option by generating code without parameter properties when useErasableSyntax is enabled. The feature is opt-in and fully backward compatible. Closes #[issue-number-if-applicable]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 issues found across 42 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/UserApi.md">
<violation number="1" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/UserApi.md:400">
P3: updateUser documentation describes the username as needing to be deleted, which is misleading for an update operation and appears to be copied from deleteUser.</violation>
</file>
<file name="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/git_push.sh">
<violation number="1" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/git_push.sh:57">
P2: Piping `git push` to `grep` in /bin/sh masks the push exit status, so CI can report success even if the push fails.</violation>
</file>
<file name="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/User.md">
<violation number="1" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/User.md:24">
P3: The example snippet uses shorthand properties (`id`, `username`, etc.) without declaring these variables, so the documentation sample is invalid TypeScript when copied.</violation>
</file>
<file name="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/api.ts">
<violation number="1" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/api.ts:437">
P2: Manually setting `Content-Type: multipart/form-data` on a FormData request strips the boundary, which can cause servers to reject multipart uploads. Let Axios/browser set the header automatically for FormData.</violation>
</file>
<file name="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/PetApi.md">
<violation number="1" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/PetApi.md:138">
P2: The `findPetsByStatus` example redeclares `status` in the same scope (`let status` then `const { status, data } = ...`), which is a SyntaxError in TypeScript/JavaScript and makes the example invalid.</violation>
<violation number="2" location="samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/PetApi.md:349">
P2: The `updatePetWithForm` example redeclares `status` in the same scope (`let status` then `const { status, data } = ...`), which is a SyntaxError and breaks the example.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| # Pushes (Forces) the changes in the local repository up to the remote repository | ||
| echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" | ||
| git push origin master 2>&1 | grep -v 'To https' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Piping git push to grep in /bin/sh masks the push exit status, so CI can report success even if the push fails.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/git_push.sh, line 57:
<comment>Piping `git push` to `grep` in /bin/sh masks the push exit status, so CI can report success even if the push fails.</comment>
<file context>
@@ -0,0 +1,57 @@
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
</file context>
| if (file !== undefined) { | ||
| localVarFormParams.append('file', file as any); | ||
| } | ||
| localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Manually setting Content-Type: multipart/form-data on a FormData request strips the boundary, which can cause servers to reject multipart uploads. Let Axios/browser set the header automatically for FormData.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/api.ts, line 437:
<comment>Manually setting `Content-Type: multipart/form-data` on a FormData request strips the boundary, which can cause servers to reject multipart uploads. Let Axios/browser set the header automatically for FormData.</comment>
<file context>
@@ -0,0 +1,1661 @@
+ if (file !== undefined) {
+ localVarFormParams.append('file', file as any);
+ }
+ localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
+ localVarHeaderParameter['Accept'] = 'application/json';
+
</file context>
| let name: string; //Updated name of the pet (optional) (default to undefined) | ||
| let status: string; //Updated status of the pet (optional) (default to undefined) | ||
|
|
||
| const { status, data } = await apiInstance.updatePetWithForm( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The updatePetWithForm example redeclares status in the same scope (let status then const { status, data } = ...), which is a SyntaxError and breaks the example.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/PetApi.md, line 349:
<comment>The `updatePetWithForm` example redeclares `status` in the same scope (`let status` then `const { status, data } = ...`), which is a SyntaxError and breaks the example.</comment>
<file context>
@@ -0,0 +1,441 @@
+let name: string; //Updated name of the pet (optional) (default to undefined)
+let status: string; //Updated status of the pet (optional) (default to undefined)
+
+const { status, data } = await apiInstance.updatePetWithForm(
+ petId,
+ name,
</file context>
|
|
||
| let status: Array<'available' | 'pending' | 'sold'>; //Status values that need to be considered for filter (default to undefined) | ||
|
|
||
| const { status, data } = await apiInstance.findPetsByStatus( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The findPetsByStatus example redeclares status in the same scope (let status then const { status, data } = ...), which is a SyntaxError in TypeScript/JavaScript and makes the example invalid.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/PetApi.md, line 138:
<comment>The `findPetsByStatus` example redeclares `status` in the same scope (`let status` then `const { status, data } = ...`), which is a SyntaxError in TypeScript/JavaScript and makes the example invalid.</comment>
<file context>
@@ -0,0 +1,441 @@
+
+let status: Array<'available' | 'pending' | 'sold'>; //Status values that need to be considered for filter (default to undefined)
+
+const { status, data } = await apiInstance.findPetsByStatus(
+ status
+);
</file context>
| |Name | Type | Description | Notes| | ||
| |------------- | ------------- | ------------- | -------------| | ||
| | **body** | **User**| Updated user object | | | ||
| | **username** | [**string**] | name that need to be deleted | defaults to undefined| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: updateUser documentation describes the username as needing to be deleted, which is misleading for an update operation and appears to be copied from deleteUser.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/UserApi.md, line 400:
<comment>updateUser documentation describes the username as needing to be deleted, which is misleading for an update operation and appears to be copied from deleteUser.</comment>
<file context>
@@ -0,0 +1,424 @@
+|Name | Type | Description | Notes|
+|------------- | ------------- | ------------- | -------------|
+| **body** | **User**| Updated user object | |
+| **username** | [**string**] | name that need to be deleted | defaults to undefined|
+
+
</file context>
| import { User } from './api'; | ||
|
|
||
| const instance: User = { | ||
| id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The example snippet uses shorthand properties (id, username, etc.) without declaring these variables, so the documentation sample is invalid TypeScript when copied.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-axios/builds/with-erasable-syntax/docs/User.md, line 24:
<comment>The example snippet uses shorthand properties (`id`, `username`, etc.) without declaring these variables, so the documentation sample is invalid TypeScript when copied.</comment>
<file context>
@@ -0,0 +1,35 @@
+import { User } from './api';
+
+const instance: User = {
+ id,
+ username,
+ firstName,
</file context>
Closes #[22540]
This change enables support for TypeScript's 'erasableSyntaxOnly' compiler
option by generating code without parameter properties when useErasableSyntax
is enabled. The feature is opt-in and fully backward compatible.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds optional erasable syntax support to the typescript-axios generator so projects using TypeScript’s erasableSyntaxOnly can compile generated clients. Opt-in and backward compatible; aligns with issue 22540 (“support for erasable syntax only”).
Written for commit d39bf0f. Summary will update on new commits.