-
-
Notifications
You must be signed in to change notification settings - Fork 411
feat: add immutable types #1350
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: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b0b035b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@smorimoto I'm a little bit unsure on when to use lodash or not in the lib, seems like there is no clear pattern on when it's applied or not. Do you have time to review the PR? |
bugbot run |
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.
Bug: Flag Ignored in API Generation
The new --make-immutable
CLI flag is defined but isn't passed through to the generateApi
function. This means the flag will be ignored and won't have any effect when used.
index.ts#L239-L281
swagger-typescript-api/index.ts
Lines 239 to 281 in b0b035b
responses: { | |
type: "boolean", | |
alias: "r", | |
description: | |
"generate additional information about request responses also add typings for bad responses", | |
default: codeGenBaseConfig.generateResponses, | |
}, | |
"route-types": { | |
type: "boolean", | |
description: "generate type definitions for API routes", | |
default: codeGenBaseConfig.generateRouteTypes, | |
}, | |
silent: { | |
type: "boolean", | |
description: "Output only errors to console", | |
default: codeGenBaseConfig.silent, | |
}, | |
"single-http-client": { | |
type: "boolean", | |
description: "Ability to send HttpClient instance to Api constructor", | |
default: codeGenBaseConfig.singleHttpClient, | |
}, | |
"sort-routes": { | |
type: "boolean", | |
description: "sort routes in alphabetical order", | |
default: codeGenBaseConfig.sortRoutes, | |
}, | |
"sort-types": { | |
type: "boolean", | |
description: "sort fields and types", | |
default: codeGenBaseConfig.sortTypes, | |
}, | |
templates: { | |
type: "string", | |
alias: "t", | |
description: "path to folder containing templates", | |
}, | |
"type-prefix": { | |
type: "string", | |
description: "data contract name prefix", | |
default: codeGenBaseConfig.typePrefix, | |
}, | |
"type-suffix": { |
index.ts#L88-L93
swagger-typescript-api/index.ts
Lines 88 to 93 in b0b035b
}, | |
"make-immutable": { | |
type: "boolean", | |
description: "makes all properties and values readonly", | |
default: codeGenBaseConfig.makeImmutable, | |
}, |
index.ts#L297-L298
swagger-typescript-api/index.ts
Lines 297 to 298 in b0b035b
await generateApi({ |
Bugbot free trial expires on September 2, 2025
Learn more in the Cursor dashboard.
In a functional codebase consumers of
swagger-typescript-api
would want to force properties and values to be immutable even if swagger spec does not havereadOnly
property.With this change one can simply add
--make-immutable
or setmakeImmutable
to force immutable types.