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

Accept x-www-form-urlencoded #15

Closed
wants to merge 4 commits into from
Closed

Conversation

joeflateau
Copy link

No description provided.

@MikeRalphson
Copy link
Contributor

Thanks for the PR! Interesting idea. Should it be extended to cover multipart/form-data as well? I wonder whether it should be behind an option flag because perhaps most API consumers wouldn't be as concerned with the formatting of formData parameters (because the format is fixed) than they are with xml or json where they may have to format the payload themselves...

@joeflateau
Copy link
Author

You're welcome! Thanks for making an awesome project.

form-data would be tough from a formatting perspective (meaning, the example could get LONG). I needed this particular change to document an asp.net api that accepts parameters through the built-in params collection that can accept form-data or x-www-form-urlencoded. I suspect there are very few apis that accept form-data and NOT x-www-form-urlencoded so not sure the extra effort is worth it.

@MikeRalphson
Copy link
Contributor

@joeflateau So this change is only where a schema is defined for a body parameter and the consumes type is application/x-www-form-urlencoded?

I'm slightly confused by where you mention

parameters through the built-in params collection that can accept form-data or x-www-form-urlencoded

Could you possibly share a snippet of the API definition either here or in a gist?

It certainly feels a little niche, but not actually against the OpenAPI 2.0 spec.

@joeflateau
Copy link
Author

I'm sorry, that was probably worded confusingly. What I'm saying there is that, in ASP.net you can read "form fields" through a collection. eg: Request.Form["my-field-123"] and it doesn't matter if the HTTP request was multipart/form-data or application/x-www-form-urlencoded you read the fields the same either way. The "params collection" I'm referring to isn't the OpenAPI Spec, it's an ASP.net thing.

@MikeRalphson
Copy link
Contributor

@joeflateau Just chasing up this so I can test it.

Could you possibly share a snippet of the API definition either here or in a gist?

@joeflateau
Copy link
Author

@MikeRalphson oh yes, sorry, totally slipped my mind. here you go: https://gist.github.com/joeflateau/cd18db5c6d31cd8aebda47b5583be35b

@MikeRalphson
Copy link
Contributor

@joeflateau Hmm, that swagger definition doesn't seem to be valid according to the specification. Only in:body parameters can have a schema property. Is it possible for you to change the in of the parameters and remove type:object (which is implied), or does that break something else for you?

@joeflateau
Copy link
Author

@MikeRalphson seems fine changing in to body and dropping the type property completely.

https://gist.github.com/joeflateau/8e82bcd346b4a862927f4c641da95020

@MikeRalphson
Copy link
Contributor

MikeRalphson commented May 14, 2017

Hmm, I'm still a bit confused and the second sample still isn't valid Swagger 2.0. Is FbAuthToken really a (JSON) object with a property access_token, or is it a simple form parameter? In the latter case it doesn't need / shouldn't have a schema at all.

@MikeRalphson
Copy link
Contributor

Hi @joeflateau - can you try your definition with the latest version? Request body parameters are now handled differently.

@MikeRalphson
Copy link
Contributor

Closing this for now - structured request body parameters should now be displayed better regardless of the produces/consumes used within v2.0 definitions.

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.

None yet

2 participants