Skip to content

Escape special characters in folder description before writing to postman.json#99

Open
Copilot wants to merge 2 commits into
add-folder-descriptionfrom
copilot/sub-pr-98
Open

Escape special characters in folder description before writing to postman.json#99
Copilot wants to merge 2 commits into
add-folder-descriptionfrom
copilot/sub-pr-98

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 6, 2026

Tag descriptions containing quotes or newlines would produce invalid JSON in the generated postman.json since they were written into the template unescaped.

Changes

  • PostmanV2Generator.addToMap: Apply formatDescription to the tag description before storing it on PostmanRequestFolder, escaping "\" and newlines → \n
  • Test: Added testAddToMapEscapesFolderDescription covering descriptions with embedded quotes and newlines
// Before: raw description written directly
tagDescription = codegenOperation.tags.get(0).getDescription();

// After: escaped before use
tagDescription = formatDescription(codegenOperation.tags.get(0).getDescription());

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: gcatanese <1771700+gcatanese@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on adding folder description to postman.json Escape special characters in folder description before writing to postman.json Mar 6, 2026
@gcatanese gcatanese marked this pull request as ready for review March 13, 2026 18:40
@gcatanese gcatanese requested a review from Copilot March 13, 2026 18:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent invalid JSON in the generated postman.json when OpenAPI tag descriptions contain special characters (notably quotes and newlines), by escaping the folder description before it’s rendered into the Postman collection template.

Changes:

  • Apply formatDescription(...) to tag descriptions in PostmanV2Generator.addToMap before creating PostmanRequestFolder.
  • Add a unit test asserting that quotes and newlines are escaped in the stored folder key/description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/com/adyen/codegen/postman/PostmanV2Generator.java Escapes tag description before storing it on PostmanRequestFolder for tag-based folder generation.
src/test/java/com/adyen/codegen/postman/PostmanV2GeneratorTest.java Adds coverage to ensure folder descriptions escape quotes and newlines when added via addToMap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +287 to 290
} else {
tagDescription = formatDescription(tagDescription);
}
}
Comment on lines 286 to 289
tagDescription = tagName + " tag";
} else {
tagDescription = formatDescription(tagDescription);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants