enryold / yii2-apidoc-generator

Yii2 Apidoc.js generator
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

Garbled success example #5

Open yairpe opened 7 years ago

yairpe commented 7 years ago

Nice and handy extension. Thanks.

I believe there's a bug that removes repeating lines from the success example and thus generates illegal json structure

The code which inserts the output is:

     * @param $str string Insert one row in output.
     */
    private function insert($str)
    {
        if(array_search($str, $this->out) === false)
        {
            $this->out[] = $str;
        }
    }

Now, because of the check for duplicates strings lines are removed. I'm pretty sure there was good reason to add this check but the fact is that it garbles the output

For example (I've numbered the lines just for the explanation) Now lines 6 and 9 are not inserted to the output because the are a duplicate of lines 2 and 5.

1  [
2      {
3          "id": 123,
4          "deleted": null
5      },
6      {
7          "id": 456,
8          "deleted": null
9      },
10 ]

So the output becomes:

1  [
2      {
3          "id": 123,
4          "deleted": null
5      },
7          "id": 456,
8          "deleted": null
10 ]

Removing the check creates a good leagal outout

enryold commented 7 years ago

Thank you @yairpe. Currently i have no time to fix, but would be great if you can do it :)