Browse Source

Format booleans as "1"/"0" in query params

Currently, `boolean` types in query params are either ``"1"` or `""`, the later case should be `"0"`, this PR fixes that
stelar7 3 years ago
parent
commit
14fbc295fe
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/Tools/WritingUtils.php

+ 2 - 1
src/Tools/WritingUtils.php

@@ -102,7 +102,8 @@ class WritingUtils
             if (!is_array($value)) {
             if (!is_array($value)) {
                 $output .= str_repeat(" ", $spacesIndentation);
                 $output .= str_repeat(" ", $spacesIndentation);
                 // Example: -----"param_name": "value"----
                 // Example: -----"param_name": "value"----
-                $output .= "$startLinesWith$quote$parameter$quote$delimiter $quote$value$quote$endLinesWith\n";
+                $formattedValue = gettype($value) === "boolean" ? ($value ? 1 : 0) : $value;
+                $output .= "$startLinesWith$quote$parameter$quote$delimiter $quote$formattedValue$quote$endLinesWith\n";
             } else {
             } else {
                 if (count($value) == 0) {
                 if (count($value) == 0) {
                     continue;
                     continue;