Prechádzať zdrojové kódy

Merge branch 'master' into v4

# Conflicts:
#	CHANGELOG.md
#	src/Tools/Globals.php
shalvah 2 rokov pred
rodič
commit
cc146b8f4d

+ 4 - 0
CHANGELOG.md

@@ -24,6 +24,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 - Basic support for overriding docs for inherited methods ([9735fdf](9735fdf150469f186bab395fcfabd042f570c50c))
 - note views may have changed
 
+## 3.37.0 (27 August 2022)
+### Modified
+- Support `"No-example"` as `example` value in `bodyParameters()` and friends ([#511](https://github.com/knuckleswtf/scribe/pull/511))
+
 ## 3.36.0 (12 August 2022)
 ### Modified
 - Support `@responseField` on Eloquent API resources ([#505](https://github.com/knuckleswtf/scribe/pull/505))

+ 3 - 0
src/Extracting/ParsesValidationRules.php

@@ -512,6 +512,9 @@ trait ParsesValidationRules
                     : null;
             }
         } else if (!is_null($parameterData['example']) && $parameterData['example'] !== self::$MISSING_VALUE) {
+            if($parameterData['example'] === 'No-example' && !$parameterData['required']){
+                return null;
+            }
             // Casting again is important since values may have been cast to string in the validator
             return $this->castToType($parameterData['example'], $parameterData['type']);
         }

+ 5 - 0
tests/Fixtures/TestRequest.php

@@ -31,6 +31,7 @@ class TestRequest extends FormRequest
             'user_id' => 'int|required',
             'room_id' => ['string'],
             'forever' => 'boolean',
+            'no_example_attribute' => 'numeric',
             'another_one' => 'numeric',
             'even_more_param' => 'array',
             'book.name' => 'string',
@@ -59,6 +60,10 @@ class TestRequest extends FormRequest
             'another_one' => [
                 'description' => 'Just need something here.',
             ],
+            'no_example_attribute' => [
+                'description' => 'Attribute without example.',
+                'example' => 'No-example',
+            ],
             'even_more_param' => [
                 'description' => '',
             ],

+ 6 - 0
tests/Strategies/GetFromFormRequestTest.php

@@ -46,6 +46,12 @@ class GetFromFormRequestTest extends BaseLaravelTest
                 'required' => false,
                 'description' => 'Just need something here.',
             ],
+            'no_example_attribute' => [
+                'type' => 'number',
+                'required' => false,
+                'description' => 'Attribute without example.',
+                'example' => null,
+            ],
             'even_more_param' => [
                 'type' => 'string[]',
                 'required' => false,