Skip to content

Commit 6095d2d

Browse files
authored
Support CommaSeparatedTuples including commas (#14535)
* Test parsing CSV values including commas * Remove commented line
1 parent 0e0cdda commit 6095d2d

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

modules/openapi-generator-cli/src/test/java/org/openapitools/codegen/cmd/utils/OptionUtilsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public void testParseCommaSeparatedTuples() throws Exception {
5252
doTupleListTest("a=1,=,c=3", asList(Pair.of("a", "1"), Pair.of("c", "3")));
5353
doTupleListTest("", emptyPairList());
5454
doTupleListTest(null, emptyPairList());
55+
doTupleListTest("a=1,b=2,c=\"3,4,5\"",
56+
asList(Pair.of("a", "1"), Pair.of("b", "2"),
57+
Pair.of("c", "\"3,4,5\"")));
58+
5559
}
5660

5761
private static void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OptionUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public static List<String> splitCommaSeparatedList(String input) {
5151
List<String> results = new ArrayList<String>();
5252

5353
if(input != null && !input.isEmpty()) {
54-
for (String value : input.split(",")) {
54+
String[] tokens = input.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1);
55+
for (String value : tokens) {
5556
if(isNotEmpty(value))
5657
results.add(value);
5758
}

0 commit comments

Comments
 (0)