nostop8 / yii2-rest-api-doc

Simple documentation generator for Yii2 REST applications based on defined API endpoints and actions annotations.
MIT License
21 stars 15 forks source link

view request body if exist file upload #9

Closed illyar80 closed 3 years ago

nostop8 commented 4 years ago

@illyar80 Hi! After we show the body field, the Yii::$app->request->bodyParams will have not expected value, which will consist actual body as a property with string value. It will also have url and method properties additionally, which should not be a part of the bodyParams, e.g.:

{"method":"POST","url":"/test","body":"{\r\n \"a\": \"\",\r\n \"b\": \"\"\r\n}"}

So I guess there's no point showing Body field until this problem is resolved. Its probably some setting in the doc.js for ajax request parameters. I'm not sure what exactly it should be. If you have time look into this and this issue will be fixed, then I can accept the pull request.

illyar80 commented 4 years ago

Hi, its not problem for my code: if (Yii::$app->request->post('body')) { $post = json_decode(Yii::$app->request->post('body'), true); } else { $post = Yii::$app->request->post(); }

illyar80 commented 4 years ago

Снимок экрана от 2020-06-04 15-42-59

nostop8 commented 4 years ago

@illyar80 this approach is breaking the consistency, because your code suppose to look as Yii::$app->request->post() instead of Yii::$app->request->post('body'). Until this issue is resolved I cannot approve the pull request. You might just use your own repository in composer.json in case this inconsistency is OK for you.

illyar80 commented 4 years ago

Ok, thank you for your explanation and for the spending time.