swagger-api / swagger-js

Javascript library to connect to swagger-enabled APIs via browser or nodejs
http://swagger.io
Apache License 2.0
2.62k stars 761 forks source link

GET request #1408

Closed alexanderteplov closed 5 years ago

alexanderteplov commented 5 years ago

Hi all. Your "swagger" is awesome!

I have this part of my yaml spec: `/users: get: tags:

I try to send request with Swagger-Client: Swagger.execute({ spec: json, operationId: "usersList", parameters: { filter: { firstName: "Peter" } } }) .then(response => { console.log("Response body: ", response.body); }) .catch(error => console.log("ERROR: ", error))

And I have that error:

ERROR: TypeError: "HEAD or GET Request cannot have a body."

When I asked myself: why? There is no reason for such strict behavior. Excluding third party library, if "swagger-js" based on it.

Can you realize support of GET request with body?

It is great comfortable to use in RESTfull API. GET request used by the same way as POST request, but with semantic difference. GET for returning obiect, POST for creating object. In body of GET request we can have all request parameters in json format, what easy describes with "swagger" and have no limitations like url parameters has.

alexanderteplov commented 5 years ago

So, I looking for this error and have found, that this is not the "swagger-js" deal, but "fetch".

shockey commented 5 years ago

@extramuros glad you figured it out! 👍