Skip to content

Conversation

J3MPA
Copy link

@J3MPA J3MPA commented Aug 5, 2025

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 have readOnly property.

With this change one can simply add --immutable flag or set immutable option to force immutable types.

Copy link

changeset-bot bot commented Aug 5, 2025

🦋 Changeset detected

Latest commit: 8f8b488

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
swagger-typescript-api Minor

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

@J3MPA J3MPA changed the title Feat/add default readonly configuration feat: add immutable types Aug 5, 2025
@J3MPA
Copy link
Author

J3MPA commented Aug 6, 2025

@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?

@smorimoto

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@J3MPA
Copy link
Author

J3MPA commented Aug 25, 2025

@smorimoto I fixed the suggestion from cursor

@smorimoto

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@J3MPA
Copy link
Author

J3MPA commented Aug 26, 2025

@smorimoto Could these changes be approved, merged and released?

@J3MPA J3MPA force-pushed the feat/add-default-readonly-configuration branch from 8689c2d to 25634c6 Compare September 1, 2025 09:20
@smorimoto

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@J3MPA
Copy link
Author

J3MPA commented Sep 5, 2025

@smorimoto Sorry for all the pings, but would be amazing with this feature. Is it ready to be merged?

@J3MPA
Copy link
Author

J3MPA commented Sep 13, 2025

@smorimoto Any updates, can we aim to have this merged?

@smorimoto
Copy link
Collaborator

I will take a look at this today. Sorry for being late. Also, how about simply making the flag “immutable”? I think it's simpler.

@J3MPA
Copy link
Author

J3MPA commented Sep 16, 2025

I will take a look at this today. Sorry for being late. Also, how about simply making the flag “immutable”? I think it's simpler.

Yes I agree, i tried following naming convention of other flags, hence the "make" part. But "immutable" is for sure better, will update it

@smorimoto
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

ArrayType: (content: unknown) => string;
StringValue: (content: unknown) => string;
BooleanValue: (content: unknown) => string;

[P1] Align CodeGenConstruct type signatures with new immutable parameters

The CodeGenConstruct typings still describe helpers like ArrayType, RecordType, InterfaceDynamicField, and Tuple as unary functions receiving a single content value. The implementation in CodeGenConfig.Ts now calls these helpers with objects that include a readonly flag (this.config.Ts.ArrayType({ readonly, content }), etc.). Any consumer overriding these constructs using the published types will still implement the old (content) => … signature and will now receive an object, resulting in [object Object] output or other breakage when the override is invoked. The declaration should be updated to reflect the new parameter shape or the runtime should continue supporting the old signature to avoid breaking existing custom code.


Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@smorimoto smorimoto added the enhancement New feature or request label Sep 16, 2025
@J3MPA
Copy link
Author

J3MPA commented Sep 17, 2025

@smorimoto I changed from makeImmutable to just immutable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants