New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to document queryParam e.g. filter[id] #637
Comments
Try out the new version 4. See the migration guide. |
@shalvah I have upgraded to v4, great work! I was not able to get query parameters as arrays working without making changes to the The below is what I did to get the
The same approach seemed to work for the PHP template:
|
I tried v4.0.2 with not success. The error is still the same. Should i open a PR? What is the use of |
Picks up on solution discussed at mpociot#637 There is an error in the proposed solution, so I fixed it and hope we can integrate this bugfix back into your repo.
I'm experiencing the same issue (with v4). |
Array query parameters are notoriously difficult to get right, primarily because there's no standard for dealing with them. Changing one thing usually breaks someone else's setup, so tread carefully. I don't totally understand your problem or solution. Please explain them again, more clearly. Does your solution handle a situation where there are multiple items in the query param array? (e.g. |
Hey Shalvah,
I got your message on the unit tests and I understand there may be side
effects.
Yes, "filter[id], filter[name]" is exactly the situation. The solution I
sent was only for bash, and should be applied to other languages, such as
Javascript, etc.
Would it be feasible to create a config/setting to enable/disable the array
handling code? I wrote the code to fall back to your original
implementation if something went wrong. I also believe there are a few more
safety checks that can be added to ensure no breaks in compatibility.
Is there a way I can help further? I may have a couple hours free if you
want a hand.
Thanks again for your work!
Em dom, 5 de jan de 2020 18:53, Shalvah <notifications@github.com> escreveu:
… Array query parameters are notoriously difficult to get right, primarily
because there's no standard for dealing with them. Changing one thing
usually breaks someone else's setup, so tread carefully.
I don't totally understand your problem or solution. Please explain them
again, more clearly. Does your solution handle a situation where there are
multiple items in the query param array? (e.g. filter[id], filter[name])?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#637?email_source=notifications&email_token=AADZB3BDRUCADGZW6LW4YPLQ4JJGBA5CNFSM4JJVZZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEAPCI#issuecomment-570951561>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADZB3FU37EAF2QBA3KQXVLQ4JJGBANCNFSM4JJVZZPQ>
.
|
i still don't understand the problem....my understanding is that the generation process converts this into
|
@shalvah An exception is thrown when you try to generate the documentation. That's because the "example code" generation for bash (and a few other languages) breaks when it receives the array instead of a string. |
I see. So, in essence, you want two changes:
should become: And then the code for handling a "list" query param value ( I understand that the second throws an exception, but why do you wish to change the first? If we're doing this, we're going all in. No config switches. |
@shalvah I wasn't the guy who supplied a code fix, if I see it correctly that was @ncatanchin. I just experienced the issue, so I commented to say that it still exists in v4. Your solution looks right to me though, the code examples should just display it as a regular string instead of an array (e.g |
@shalvah Could you explain why this was added Mpociot\ApiDoc\Tools\Generator::generateConcreteSampleForArrayKeys? In General if you insert params that are named
i can not generate the docs anymore. I would have to override the templates to generate the docs. The rease for that is in generateConcreteSampleForArrayKeys which will parse filter[id] and transform it into an array. |
fixes indentation problems in @lucianobargmann's PR for #637
Fixed in #700 |
I use a filter pages which requires me to define filter params like.
This seems to break doc generation. Both languages bash and javascript field to compile with v3.17.1 of laravel-apidoc-generator.
This happends because the cleanQueryParameters are of the route is broken during the markdown generation step.
this should be
I tracked it down to
Mpociot\ApiDoc\Tools\Generator::generateConcreteSampleForArrayKeys
. If i comment the use of this function out markdown generates fine.Is there a way to enable handle ?
The text was updated successfully, but these errors were encountered: