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

feat(empty-response): handle empty response in json deserialize #43

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

sufyankhanrao
Copy link
Collaborator

@sufyankhanrao sufyankhanrao commented Jul 4, 2024

What

This PR fixes an issue where ApiHelper::json_deserialize and response_handler returned the same empty payload (nil or empty string) or default values in case of scalar types instead of nil when the API response was missing.

The change ensures the utility and response handler behaves as expected and returns nil for empty responses.

Why

  • To return a proper value (i.e. None) when the response payload is empty.

closes #42

Type of change

Select multiple if applicable.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause a breaking change)
  • Tests (adds or updates tests)
  • Documentation (adds or updates documentation)
  • Refactor (style improvements, performance improvements, code refactoring)
  • Revert (reverts a commit)
  • CI/Build (adds or updates a script, change in external dependencies)

Dependency Change

If a new dependency is being added, please ensure that it adheres to the following guideline https://github.com/apimatic/apimatic-codegen/wiki/Policy-of-adding-new-dependencies-in-the-core-libraries

Breaking change

If the PR is introducing a breaking change, please ensure that it adheres to the following guideline https://github.com/apimatic/apimatic-codegen/wiki/Guidelines-for-maintaining-core-libraries

Testing

List the steps that were taken to test the changes

Checklist

  • My code follows the coding conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added new unit tests

This commit fixes an issue where ApiHelper::json_deserialize and response_handler returned the same empty payload (nil or empty string) or default values in case of scalar types instead of nil when the API response was missing.

The change ensures the utility and response handler behaves as expected and returns nil for empty responses.

closes #42
@sufyankhanrao sufyankhanrao added the bug Something isn't working label Jul 4, 2024
@sufyankhanrao sufyankhanrao requested a review from asadali214 July 4, 2024 13:03
@sufyankhanrao sufyankhanrao self-assigned this Jul 4, 2024
@sufyankhanrao sufyankhanrao added enhancement New feature or request and removed bug Something isn't working labels Jul 5, 2024
@sufyankhanrao sufyankhanrao changed the title fix(empty-response): handle empty response in json deserialize feat(empty-response): handle empty response in json deserialize Jul 5, 2024
Copy link

sonarqubecloud bot commented Jul 5, 2024

Copy link
Contributor

@asadali214 asadali214 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good to me

@sufyankhanrao sufyankhanrao merged commit a3e5df4 into main Jul 9, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return nil when the response payload is empty
2 participants