浏览代码

Switch to number rather than float type

shalvah 4 年之前
父节点
当前提交
66993d2d2c

+ 2 - 2
docs/documenting/documenting-endpoint-body-parameters.md

@@ -7,9 +7,9 @@ Scribe can get information about your endpoint's body parameters in two ways:
 To describe body parameters for your endpoint, use the `@bodyParam` annotation on the method handling it.
 
 The `@bodyParam` annotation takes the name of the parameter, its type, an optional "required" label, and then its description. Valid types:
-- `int` / `integer`
 - `string`
-- `number` / `float`
+- `integer`
+- `number`
 - `boolean`
 - `array`, `object` (see [Handling array and object parameters](#handling-array-and-object-parameters) below)
 - `file` (see [Documenting File Uploads](#documenting-file-uploads) below)

+ 3 - 2
src/Extracting/ParamHelpers.php

@@ -116,7 +116,7 @@ trait ParamHelpers
 
     /**
      * Normalizes the stated "type" of a parameter (eg "int", "integer", "double")
-     * to a number of standard types (integer, boolean, float). Will return the input if no match.
+     * to a number of standard types (integer, boolean, number). Will return the input if no match.
      *
      * @param string $type
      *
@@ -131,7 +131,8 @@ trait ParamHelpers
         $typeMap = [
             'int' => 'integer',
             'bool' => 'boolean',
-            'double' => 'float',
+            'double' => 'number',
+            'float' => 'number',
         ];
 
         return $typeMap[$type] ?? $type;

+ 1 - 1
tests/Fixtures/TestController.php

@@ -76,7 +76,7 @@ class TestController extends Controller
      * @bodyParam yet_another_param object required Some object params.
      * @bodyParam yet_another_param.name string required Subkey in the object param.
      * @bodyParam even_more_param array Some array params.
-     * @bodyParam even_more_param.* float Subkey in the array param.
+     * @bodyParam even_more_param.* number Subkey in the array param.
      * @bodyParam book.name string
      * @bodyParam book.author_id integer
      * @bodyParam book[pages_count] integer

+ 2 - 2
tests/Strategies/BodyParameters/GetFromBodyParamTagTest.php

@@ -26,7 +26,7 @@ class GetFromBodyParamTagTest extends TestCase
             new Tag('bodyParam', 'yet_another_param object required Some object params.'),
             new Tag('bodyParam', 'yet_another_param.name string required Subkey in the object param.'),
             new Tag('bodyParam', 'even_more_param array Some array params.'),
-            new Tag('bodyParam', 'even_more_param.* float Subkey in the array param.'),
+            new Tag('bodyParam', 'even_more_param.* number Subkey in the array param.'),
             new Tag('bodyParam', 'book.name string'),
             new Tag('bodyParam', 'book.author_id integer'),
             new Tag('bodyParam', 'book[pages_count] integer'),
@@ -75,7 +75,7 @@ class GetFromBodyParamTagTest extends TestCase
                 'description' => 'Some array params.',
             ],
             'even_more_param.*' => [
-                'type' => 'float',
+                'type' => 'number',
                 'description' => 'Subkey in the array param.',
                 'required' => false,
             ],

+ 1 - 1
tests/Unit/OpenAPISpecWriterTest.php

@@ -258,7 +258,7 @@ class OpenAPISpecWriterTest extends TestCase
                     'description' => 'Number param',
                     'required' => false,
                     'value' => 186.9,
-                    'type' => 'float',
+                    'type' => 'number',
                 ],
             ],
         ]);