guzzle / guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.
MIT License
253 stars 78 forks source link

Header's keys are not the keys from the array #122

Closed mims92 closed 2 years ago

mims92 commented 7 years ago

Following the documentation,'

Headers that are of type object will be added as multiple headers to a request using the key of the input array as the header key (http://guzzle3.readthedocs.io/webservice-client/guzzle-service-descriptions.html#header-location).

But it's not the case!

"getChocolate": {
      "httpMethod": "GET",
      "uri": "api/getChocolate/{id}",
      "parameters": {
       "id": {
          "required": true,
          "location": "uri",
          "type": "integer"
        },
        "header": {
          "required": false,
          "location": "header",
          "type": "object"
        }
      }
}

So if I pass ['myCustomHeader' => '1'] to the header parameter, I would assume having in the request header: myCustomHeader: 1. Actually, I have header: 1.

Is this a bug? Using Guzzle6

Konafets commented 7 years ago

It looks like this is gone long time ago. Can't even find this described behavior in the origin code of Guzzle3 anymore. My first guess is that the docs are outdated.

alexis-gruet-deel commented 7 years ago

I don't know if this can help, but i confirm we facing the same issue right now, As a workaround, you can define the header name as the key for the array like this

'X-Access-Token' => [
     'required' => true,
     'location'  => 'header',
     'type'        => 'string'
]
mims92 commented 7 years ago

I don't think it's a workaround. I think it's the correct way of doing this and the doc is outdated as Konafets mentioned.

GrahamCampbell commented 2 years ago

Closing since stale - I'm doing a cleanup across the whole organization, to enable us to focus on the tickets that are still live and have interest. Please feel free to open a new issue if this still is important to you. :)