Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Operations extends is broken in 1.1.1 #145

Closed
delamart opened this issue May 17, 2017 · 5 comments
Closed

Operations extends is broken in 1.1.1 #145

delamart opened this issue May 17, 2017 · 5 comments

Comments

@delamart
Copy link

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.

@Konafets
Copy link
Contributor

Can you post your faling test?

@delamart
Copy link
Author

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.

@delamart
Copy link
Author

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

Konafets added a commit that referenced this issue May 19, 2017
Revert the commit 2b191b1 since it introduced a regression which affects the usage of operation extension.

See #145
@Konafets
Copy link
Contributor

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

@delamart
Copy link
Author

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

Konafets added a commit that referenced this issue Oct 6, 2017
Revert the commit 2b191b1 since it introduced a regression which affects the usage of operation extension.

See #145
Konafets added a commit that referenced this issue Oct 6, 2017
Thanks to @delamart for reporting and providing the test.

Closes #145, closes #146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants