Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/unify response handling #7577

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

Closed

Conversation

@jmglsn
Copy link
Contributor

@jmglsn jmglsn commented Feb 4, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This changes should uniform the response data deserialization process. I recently faced the problem that the expected response model for non default response codes like 404 where not exposed inside the ApiException. This was caused by the different handling of the initial data.
But as you can see there are some other changes, maybe we can see this as a suggestion - that we could discus.

  • The async functions use the same response handling as the sync implementations now. This makes sure that we don't face different response data. The previous implementation missed any exception model mapping.
  • The client is using php 7.1 syntax, I know this is another breaking change, but php 5 is almost dead.
  • We have different exceptions, ApiException as base and MappedApiException for responses that are defined by specification.
  • I also changed the signature of ApiException.
  • I dropped the dev requirements for phpcs and phpcs-fix, as this are more or less just tools that we might suggest to adapt the code, but for the generated client itself, they are not required.
  • phpUnit is now version 6 / 7.

I see some more possible things that I would like to discus with you.

  • Can we avoid static calls? Maybe inject the ObjectSerializer?
  • Should be export / generate interfaces?
  • What about another package for the shared client logic? So we could focus more on model / interface generation - and provide different client implementations, not only based on guzzle.
  • What about the tests that we generate? Some of them are broken - not by this change. How can we avoid this in future?

I'm sorry for the size of the PR and the BC breaks, but please see this as an suggestion.

jmglsn added 4 commits February 4, 2018 16:49
This adds a more unified handling for response code to type mapping.
This fixes the deserialization for non default responses, which in
previously implementation were only based on exception logic.
This approach assumes that when the specification defines an possible
response code outside of the default one, the client should handle the
result in the same way as the default, but still propagate the result
as exception. This exception is a MappedException, as it's defined by
specification. Any other unexpected response is still an ApiException.
It's a BC break.
- The model if ApiException is changed, as it's now more
generic.
- The client makes use of php 7.1 features, I assume it's a required
 step. (https://secure.php.net/supported-versions.php)
 This includes return type hinting. (For operations with 'void' only.)
This changes phpUnit to 6.0 / 7.0, according to php version requirement.
I moved the code style dependencies to `suggest` as cs-fixer and phpcs
are not a development requirement, they can be used to modify the code
but only if wanted.
Asynchronous operations will now use the same mapping routines as the
sync operations do. This makes sure that non default responses can be
mapped too.
@jmglsn jmglsn force-pushed the feature/unify-response-handling branch from eeeebd6 to 9b06da0 Compare February 5, 2018 08:18
Copy link
Contributor

wing328 commented Feb 5, 2018

The client is using php 7.1 syntax, I know this is another breaking change, but php 5 is almost dead.

Would it be possible to keep the PHP client working with PHP 5.x? This is not to say we encourage PHP developers not to upgrade to 7.x but seems like a lot of users are still using PHP 5.x

For Java, there's an option supportJava6 to make the Java API client compatible with JDK6 so that developers still have the option to run it in their environment if they can't JDK to the latest version for whatever reason.

jmglsn and ackintosh reacted with thumbs up emoji

Copy link
Contributor

Thank you for your suggestion!
I think that we should keep the PHP client works with currently supported versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

v2.4.0

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /