Skip to content

Fix up YAML serialisation to understand AutoRest property renaming #209

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

Merged

Conversation

itowlson
Copy link
Contributor

AutoRest renames properties such as 'namespace' and 'readOnly' to avoid clashes with keywords in common .NET languages. It uses JsonPropertyAttribute to map these back to the right names in JSON. However, the YAML serialiser isn't aware of the JSON mappings, so loading YAML including such properties fails (similarly, writing them out produces the wrong YAML text). This PR adds a custom type inspector to the YAML serialisation stack which performs the additional mapping needed.

Fixes #208.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 14, 2018
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 14, 2018
@itowlson itowlson added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 15, 2018
@itowlson
Copy link
Contributor Author

Don't merge this yet - we might be able to bypass this runtime fixup by changing our AutoRest config to emit YamlMemberAttribute. I'll look into this.

@tg123
Copy link
Member

tg123 commented Oct 16, 2018

it is tough to modify autorest generator, I think.

@itowlson
Copy link
Contributor Author

itowlson commented Oct 16, 2018

@tg123 Yeah... I have been looking through the generation scripts and I can see where we do some sed-based post-processing but can't see any AutoRest config that would be easy to tweak. We might be able to add another sed step that duplicates every

[JsonProperty(PropertyName = "...")]

into

[JsonProperty(PropertyName = "..."), YamlMember(Alias = "...")]

The relevant post-processing is around https://github.com/kubernetes-client/gen/blob/087e4b4d9b4e40973a24f848b47f0dacc08e9160/openapi/csharp.sh#L62. My sed-fu is rusty but I think it bears investigating...

@itowlson itowlson removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2018
@itowlson
Copy link
Contributor Author

itowlson commented Nov 5, 2018

Let's give up on the AutoRest config approach for now, and go with this. Please review @brendandburns @tg123 - thanks!

CI failure looks like the known certificate test flake.

@brendandburns
Copy link
Contributor

/lgtm
/approve

@itowlson can we get a rebase? I fixed (well, commented out) that test :)

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 7, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, itowlson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 9f1669b into kubernetes-client:master Feb 12, 2019
@twitchax
Copy link
Contributor

twitchax commented Feb 12, 2019

@tg123 Yeah... I have been looking through the generation scripts and I can see where we do some sed-based post-processing but can't see any AutoRest config that would be easy to tweak. We might be able to add another sed step that duplicates every

[JsonProperty(PropertyName = "...")]

into

[JsonProperty(PropertyName = "..."), YamlMember(Alias = "...")]

The relevant post-processing is around https://github.com/kubernetes-client/gen/blob/087e4b4d9b4e40973a24f848b47f0dacc08e9160/openapi/csharp.sh#L62. My sed-fu is rusty but I think it bears investigating...

@fearthecowboy may be interested in this feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants