Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How do you add parameters to formData payload ? #16

Closed
josephmisiti opened this issue Apr 15, 2015 · 8 comments
Closed

How do you add parameters to formData payload ? #16

josephmisiti opened this issue Apr 15, 2015 · 8 comments

Comments

@josephmisiti
Copy link

I have a post call, I am trying to add parameters to formdata with no success

@fotinakis
Copy link
Owner

Can you give a bit more info? What do your swagger-blocks definitions look like and how are they not working?

@josephmisiti
Copy link
Author

here is an example

      swagger_path '/sessions' do
        operation :post do
          key :description, 'Login To Vestorly Platform'
          key :operationId, 'login'
          key :consumes, [
            "application/x-www-form-urlencoded"
          ]
          key :tags, [
            'session'
          ]
          parameter do
            key :name, :username
            key :in, :formData
            key :description, 'Username in the XXXX platform'
            key :required, true
            key :type, :string
          end

          parameter do
            key :name, :password
            key :in, :formData
            key :description, 'Password in XXXX Platform'
            key :required, true
            key :type, :string
          end

          response 200 do
            key :description, 'Response'
            schema do
              key :'$ref', :Session
            end
          end
        end
      end

Here is the call that works in CURL:

curl -X POST https://www.example.com/api/v2/sessions
  -d "username=USERNAME"
  -d "password=PASSWORD"

I cannot get swagger-blocks to send those username + password parameters in the post. Have tried every type of in parameter (header,path,query,formData, etc)

@josephmisiti
Copy link
Author

also according to swaggers 2.0 spec, you can use the :formData parameter:

https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md

@fotinakis
Copy link
Owner

That looks correct to me, except I don't understand what you mean by "get swagger-blocks to send those username + password parameters in the post"—Swagger::Blocks doesn't send anything, it's simply a way to define JSON in the Swagger style, for example as input to Swagger UI for generating API docs—it has nothing to do with actually how your server handles data.

If the output of your /apidocs endpoint (see main README) is incorrect, that's something I can help you with, but otherwise it sounds unrelated to swagger-blocks. Closing for now, but feel free to comment with more info if you think it is actually swagger-blocks related.

@josephmisiti
Copy link
Author

Sorry - I see why that is confusing. I meant when I generate swagger.json
and try to use this method in Swagger UI, the post does not send formdata.

As an example, go here: http://developers.vestorly.com/v2/#!/session/#

and add a random username/password.

'username' not found is the response because it is not being sent in the request

On Wed, Apr 15, 2015 at 4:13 PM, Mike Fotinakis notifications@github.com
wrote:

That looks correct to me, except I don't understand what you mean by "get
swagger-blocks to send those username + password parameters in the
post"—Swagger::Blocks doesn't send anything, it's simply a way to define
JSON in the Swagger style, for example as input to Swagger UI
https://github.com/swagger-api/swagger-ui for generating API docs—it
has nothing to do with actually how your server handles data.

If the output of your /apidocs endpoint (see main README) is incorrect,
that's something I can help you with, but otherwise it sounds unrelated to
swagger-blocks. Closing for now, but feel free to comment with more info if
you think it is actually swagger-blocks related.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@fotinakis
Copy link
Owner

Can you check that the swagger.json looks correct according to the spec and maybe manually fiddle with it until it works with Swagger UI the way you expect? Unfortunately this sounds like you're just missing some part of the configuration between Swagger JSON and Swagger UI, but not actually a problem with how swagger-blocks generates JSON.

@josephmisiti
Copy link
Author

the issue was with swagger-ui: swagger-api/swagger-ui#838

sorry for wasting your time :)

@fotinakis
Copy link
Owner

Not a waste, glad you found it. 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants