Skip to content
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

Adjusted language examples to properly display application/x-www-form… #331

Conversation

rickdubiel
Copy link

This PR provides support for application/x-www-form-urlencoded requests to be displayed properly within the various language examples. The app I'm working with is using Laravel Passport and I was needing a way to display to users how to obtain an access token via the following URL (which uses application/x-www-form-urlencoded under the hood).

https://laravel.com/docs/8.x/passport#retrieving-tokens

I'm not exactly proficient in all of the languages but used my best judgement. Below are some of the before/after screenshots. With the exception of python, application/x-www-form-urlencoded expects parameters instead of json so those are what the adjustments are focused on.

bash (before)
image

bash (after)
image

javascript (before)
image

javascript (after)
image

php (before)
image

php (after)
image

The php demo was hiding the Content-Type header, and I know you (@shalvah) mentioned here (#330) that this is because the Grizzly library that the examples are using automatically add those for you, but I still believe it'd be best to explicitly display those to the users integrating with the documentation. Anything to make it easier right? Plus, the Guzzle docs just mention that Content-Type headers are only set when no Content-Type header is already present. Well in this case one is being explicitly provided and should be displayed. Another part of the issue here, and maybe the bigger part of the issue, was that there was no way to display the body type of "form_params" instead of "json" (which the oauth/token example doesn't work when using json).

https://docs.guzzlephp.org/en/stable/request-options.html#form-params

python (before)
image

python (after)
image

Not a python user so I hope is correct.

Thanks for your time!

@shalvah
Copy link
Contributor

shalvah commented Sep 27, 2021

Okay, this should be fine.

@shalvah shalvah merged commit 58ce25e into knuckleswtf:master Sep 27, 2021
@rickdubiel rickdubiel deleted the adjust-language-examples-for-x-www-form-urlencoded-requests branch September 27, 2021 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants