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

Default content-type for generated PUT request #78

Open
pabuisson opened this issue Apr 3, 2017 · 4 comments
Open

Default content-type for generated PUT request #78

pabuisson opened this issue Apr 3, 2017 · 4 comments

Comments

@pabuisson
Copy link

pabuisson commented Apr 3, 2017

Hi guys,

I'm using grape-swagger-rails (0.3.0) to generate the documentation for a JSON API. I have an issue with all the actions expecting a payload in JSON format : indeed, the documentation generates a request body with the application/x-www-form-urlencoded format, and my API only handles application/json format.

capture d ecran 2017-04-03 a 17 49 43

Therefore, all the "Try it out" actions on the documentation for POST/PUT/PATCH requests are non-functional.

I've tried to manually add a Content-Type header in the GrapeSwaggerRails initialization section, but it doesn't seem to be taken into account :

GrapeSwaggerRails.options.headers[ 'Content-Type' ] = 'application/json'

Am I missing something in the configuration of my endpoints / of grape-swagger-rails here ? I've found nothing around here in the documentation.

EDIT: actually it looks like the payload is correctly understood by my API endpoint on POST and PATCH, but not on PUT requests... in case it helps. Any clues ? When I click "Try it out", I get this in the console for a PUT request only :

capture d ecran 2017-04-03 a 18 02 25

@pabuisson pabuisson changed the title Default content-type for generated request Default content-type for generated PUT request Apr 3, 2017
@anelson425
Copy link

I am also seeing the same issue as documented here. @pabuisson did you ever find a solution for this?

@pabuisson
Copy link
Author

pabuisson commented Oct 17, 2017

@anelson425 well to be honest, we've kind of reduced our usage of grape-swagger so it's not that big a deal for us anymore. And re-reading this issue, I'm thinking that it must be coming from the underlying swagger-ui rather than grape-swagger-rails itself which mostly seems to be a wrapper around swagger. I found several issues in swagger-ui github issues, maybe there's more stuff over there about this problem.

@anelson425
Copy link

@pabuisson I found out yesterday that setting the param_type to 'body' in the documentation for the parameter seemed to fix my issue.

requires :body, documentation: { type: Entities::MyEntity, is_array: true, param_type: 'body' }

@h4ckbarth
Copy link

@anelson425, thank you so much, i was making a doc for my API and wasn't able to find a workaround for this. This fixed my issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants