StydeNet / enlighten

Enlighten your APIs with auto-generated documentation
MIT License
575 stars 32 forks source link

Fix replaceValue method crash when paylod is just a string #56

Closed emilianotisato closed 3 years ago

emilianotisato commented 3 years ago

In all cases we are assuming that the response payload to pars with Styde\Enlighten\Models\ReplacesValues trait is either null or an object/array. But when we are returning just a plain string like:

        return response()->json('Unsubscription was successfully', 200);

Then we get an exception coz array_intersect_key can't use the string (see attached image).

This fix will return the plain string response if we cant json decode it. Fixes #55

sileence commented 3 years ago

@emilianotisato thanks for the PR! Please also send a test next time. I just added one for this fix.