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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Operations extends is broken in 1.1.1

delamart opened this issue · comments

I just upgraded to version 1.1.1 and my unit tests stopped working because a parameter is no longer being set in my commands. Version 1.1.0 works fine.

I used the extends option like this:

<?php
        $ops['abstract_json_operation' => [
                'httpMethod' => 'POST',
                'responseModel' => 'result',
                'parameters' => [
                    'format' => [
                        'type' => 'string',
                        'default' => 'json',
                        'location' => 'formParam',
                    ],
                ],
            ],
            'checkAccount'] => [
                'extends' => 'abstract_json_operation',
                'uri' => '/api/checkAccount',
                'parameters' => [
                    'username' => [
                        'required' => true,
                        'type' => 'string',
                        'location' => 'formParam',
                    ],
                ]
            ]
        ];

The parameter format=json was being set correctly on all commands but now I have to set it manually in the command if I want it to work.

Can you post your faling test?

Sorry can't post my code as is, and technically my unit tests are more integration tests as I connect to a live API (test server).

Basically I have the above operations and use the following model:

$models['result' => [
                'type' => 'object',
                'additionalProperties' => [
                    'location' => 'json'
                ]
        ]
];

I use a \GuzzleHttp\Client with a custom Handler to set HTTP Basic Auth on every request and
a GuzzleHttp\Command\Guzzle\GuzzleClient with the above operations and models as GuzzleHttp\Command\Guzzle\Description.

And when I do $guzzle_client-> checkAccount(['username' => 'user']) the format parameter is set in version 1.1.0 and I get the expected result from my api. But in version 1.1.1, I need to do $guzzle_client-> checkAccount(['username' => 'user', 'format' => 'json']) to get the expected response from my API.

If I have some time I can try and provide some simple test code to reproduce this. The issue could still be linked to my external API but since the behavior clearly changes between the two versions I kind of doubt it.

Ok I had time to write a quick test. I forked the project and added a test which works with tag 1.1.0 but no longer in master.

See commit here: https://github.com/delamart/guzzle-services/commit/2d50fa4fb9f6ac4f65a6271f7d7079be91b396aa

@delamart Thanks for your test. This helped to find the culprit.

Great, thanks I upgraded to 1.1.2 and my lib works again.