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

Autorest violations fixes in RecoveryServices.Backup #1805

Conversation

AutorestCI
Copy link
Contributor

Generated from RestAPI PR: Azure/azure-rest-api-specs#2208

@lmazuel lmazuel changed the title Automatic PR from RestAPI-PR2208 Autorest violations fixes in RecoveryServices.Backup Jan 19, 2018
@DheerendraRathor
Copy link
Contributor

@lmazuel Do you know why version.py has empty version string?

@lmazuel
Copy link
Member

lmazuel commented Jan 22, 2018

@DheerendraRathor Yes, I'm change it back to next release version.

'can_re_register': {'key': 'canReRegister', 'type': 'bool'},
'container_id': {'key': 'containerId', 'type': 'str'},
'protected_item_count': {'key': 'protectedItemCount', 'type': 'long'},
'dpm_agent_version': {'key': 'dpmAgentVersion', 'type': 'str'},
'dpm_servers': {'key': 'DPMServers', 'type': '[str]'},
'upgrade_available': {'key': 'UpgradeAvailable', 'type': 'bool'},
'dpm_servers': {'key': 'dpmServers', 'type': '[str]'},
Copy link
Member

Choose a reason for hiding this comment

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

@DheerendraRathor Could you confirm this is the actual EXACT case used by your endpoint?
We have some issues with the Swagger linter right now, where people fix the Swagger when they shouldn't and I become very careful when I see a case change.
If this is not the the EXACT case (case sensitive), a new PR needs to be made to fix the Swagger.

Copy link
Contributor

Choose a reason for hiding this comment

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

Service endpoints are case-insensitive, though these will be the actual cases returned by service.
Btw how deserialization is handled in msrest? Is it case-sensitive?

Copy link
Member

@lmazuel lmazuel Jan 22, 2018

Choose a reason for hiding this comment

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

Deserialization is case-sensitive in all SDK language except C#.... This is the expected behavior for a JSON return (JSON is case-sensitive).
We have trouble currently because:

  • C# doesn't care about case sensitivity (that's a C# design flaw, not a feature)
  • The linter screams if this is not camelCase, mixing-up promoting good behavior (when you still can change your server) and asking Swagger change. If your server is already impossible to change, the right fix is not to change the Swagger, but to tell the linter to surpress the warnings because it's too late to change the server.

TL;DR; If this is output from Azure, and if you return "DPMServers" in the actual JSON, it won't deserialize with "dpmServers".

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, server will return "dpmServers". Though old SDKs will be broken then.

Regarding #1, I'll call that a feature as that is the common implementation across libraries is to be case insensitive. Since Python json library, deserializes into dict and not class instance, that creates problem in python (standard implementation).

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's common in the C# world to consider JSON case-insensitive, but not in other language :). I insist on others, it's Python, NodeJS and more language.
Note too that it's a requirement of Swagger:
https://swagger.io/specification/#format-11

  • All field names in the specification are case sensitive.

Copy link
Contributor

Choose a reason for hiding this comment

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

So other than this, PR looks good to me for merge. Tests are failing which I'll update in separate PR.

Regarding deserialization of JSON in rest api - I'm speaking with my experience on Newtonsoft, Golang std JSON unmarshalling and Python framework Django-Rest-Framework. They all have fallback from case-sensitivity to case-insensitivity if there is no exact case match.

Copy link
Member

Choose a reason for hiding this comment

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

@DheerendraRathor I can't merge this PR with the broken tests, this would break my "master" CI. I gave you permissions to push in that branch:
https://github.com/AutorestCI/azure-sdk-for-python/invitations

You can also work from your fork and cherry-pick the generation from here, at your convenience.

@codecov-io
Copy link

Codecov Report

Merging #1805 into master will increase coverage by 0.04%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1805      +/-   ##
==========================================
+ Coverage    52.8%   52.84%   +0.04%     
==========================================
  Files        4577     4663      +86     
  Lines      112520   113888    +1368     
==========================================
+ Hits        59412    60184     +772     
- Misses      53108    53704     +596
Impacted Files Coverage Δ
...esbackup/models/backup_resource_config_resource.py 71.42% <ø> (ø) ⬆️
...veryservicesbackup/models/operation_result_info.py 62.5% <ø> (ø) ⬆️
...veryservicesbackup/models/mab_protection_policy.py 55.55% <ø> (ø) ⬆️
...backup/models/export_jobs_operation_result_info.py 55.55% <ø> (ø) ⬆️
...ackup/models/workload_protectable_item_resource.py 100% <ø> (ø) ⬆️
...recoveryservicesbackup/models/azure_iaa_svm_job.py 100% <ø> (ø) ⬆️
...ryservicesbackup/models/protected_item_resource.py 100% <ø> (ø) ⬆️
...eryservicesbackup/models/iaas_vm_backup_request.py 100% <ø> (ø) ⬆️
...esbackup/models/iaas_vmilr_registration_request.py 100% <ø> (ø) ⬆️
...ckup/models/operation_status_jobs_extended_info.py 55.55% <ø> (ø) ⬆️
... and 403 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58b64f4...a978a7c. Read the comment docs.

@DheerendraRathor
Copy link
Contributor

@lmazuel Updated tests!

@lmazuel
Copy link
Member

lmazuel commented Jan 25, 2018

@DheerendraRathor Awesome!
May I ask you:

  • When do you want this release? asap or specific date?
  • A note for the ChangeLog. Either directly on HISTORY.txt, or by text in this PR and I do it.
    Thanks!!!

@DheerendraRathor
Copy link
Contributor

@lmazuel Sorry for late update, I'll come up with proper changelog soon after discussing it with manager and PMs.

@lmazuel lmazuel changed the base branch from master to restapi_auto_recoveryservicesbackup/resource-manager February 21, 2018 22:39
@lmazuel lmazuel merged commit a20ec9b into Azure:restapi_auto_recoveryservicesbackup/resource-manager Feb 21, 2018
@lmazuel
Copy link
Member

lmazuel commented Feb 21, 2018

Merge into RP branch #2033

@lmazuel lmazuel deleted the RestAPI-PR2208 branch February 21, 2018 22:40
AutorestCI added a commit that referenced this pull request Feb 28, 2018
* Generated from ee4507d

* Update version.py

* Updated tests and recordings for recoveryservices.backup
AutorestCI added a commit that referenced this pull request Mar 7, 2018
* Generated from ee4507d

* Update version.py

* Updated tests and recordings for recoveryservices.backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants