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

What am i doing wrong ? #161

Closed marcoooo closed 5 years ago

marcoooo commented 6 years ago

Hi all. my services declares a method "list" as follow:

"operations": {
    "list": {
    "httpMethod": "GET",
    "uri": "contacts",
    "summary": "List all contact",
    "responseModel": "ContactList",
    "parameters": {
      "card": {
        "type": "boolean",
        "location": "query",
        "required": false,
        "summary": "if true: Return only contacts with or without a loyalty card.",
         "filters": [
          "json_encode"
        ]
     }
   } 
},

In my simpe test case:

$client = ContactApiClient::initClient('TOKENAUTH');
var_dump($client->list(["card" => true]));

I got this error:

GuzzleHttp\Command\Exception\CommandException : 
Validation errors: **[card] must be of type boolean** 
in .../vendor/guzzlehttp/guzzle-services/src/Handler/ValidatedDescriptionHandler.php:76
tlorens commented 5 years ago

If 'card' is mean to be a parameter, shouldn't {card} be included in the defined uri?

'uri': "contacts/{card}"

alexdpunkt commented 5 years ago

Probably it's because of the json_encode filter on your parameter, which casts your boolean true to a string "true".

@tlorens: no it shouldn't, because the specified location is query. This can be found in the descriptions documentation

marcoooo commented 5 years ago

Probably it's because of the json_encode filter on your parameter, which casts your boolean true to a string "true".

@tlorens: no it shouldn't, because the specified location is query. This can be found in the descriptions documentation

Yes this was the reason, I finally found a workaround. Thanks for your help anyway.