-
-
Notifications
You must be signed in to change notification settings - Fork 528
Stop trimming whitespace other than linebreaks in string values #1269
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
Conversation
🦋 Changeset detectedLatest commit: 63fc53a 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 |
@@ -273,7 +273,7 @@ export function tsUnionOf(...types: (string | number | boolean)[]): string { | |||
/** escape string value */ | |||
export function escStr(input: any): string { | |||
if (typeof input !== "string") return JSON.stringify(input); | |||
return `"${input.trim().replace(DOUBLE_QUOTE_RE, '\\"')}"`; | |||
return `"${input.replace(LB_RE, "").replace(DOUBLE_QUOTE_RE, '\\"')}"`; |
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.
👍 this is a smarter way to handle it
Hm this seems to now be generating this type in the Stripe API example: - name?: string;
+ name?: string | ""; This is on the right track but I think we’ll need to add a couple more tests before shipping |
Oh my god this may have actually been a bug that was fixed 🙃 name:
anyOf:
- maxLength: 5000
type: string
- enum:
- ''
type: string That kinda looks right to me! But will poke through the other changes to see if anything else is unexpected |
Seems to me that the change in the Stripe API you mention is actually the result of a change in the source OpenAPI yaml, not related to the code change in this PR.
|
Changes
This PR attempts to fix #1224 while minimizing other impact.
How to Review
The unit test gives a clear example of the scenario in which the behaviour is currently not as expected. The code change is required to make the unit test pass.
Checklist
docs/
updated (if necessary) -> Not necessarypnpm run update:examples
run (only applicable for openapi-typescript) -> No changes produced?