Skip to content

#4241, #4236 Add cutom Json serializer and proxy settings to config #4466

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PeterTriebe
Copy link
Contributor

@PeterTriebe PeterTriebe commented Nov 12, 2019

#4236 Add proxy settings to config
This was needed because in net-core 2x its not possible to set a global proxy.

#4241 Add json serializer settings to config
This was needed to change the serializer settings. In my case i wanted to ignore null entries.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@PeterTriebe
Copy link
Contributor Author

PeterTriebe commented Nov 12, 2019

@mandrean (2017/08), @jimschubert (2017/09) @frankyjuang (2019/09)
Plsease take a look. Thanks :-)

@PeterTriebe
Copy link
Contributor Author

How I can rebuild CircleCI? I generated some pedstore things..

@jimschubert
Copy link
Member

@PeterTriebe Thanks for the contribution! I've triggered the build for you.

@@ -223,6 +225,13 @@ namespace {{packageName}}.Client
/// <value>The access token.</value>
public virtual string AccessToken { get; set; }


/// <inheritdoc />
public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings();
Copy link
Member

@jimschubert jimschubert Nov 13, 2019

Choose a reason for hiding this comment

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

I think this will need to be moved elsewhere… maybe as a constructor argument for ApiClient or as a settable property (or both?).

Configuration should be decoupled from framework implementation. For example, ApiClient is tightly coupled to RestSharp and JSON.net. Having Configuration rely only on "standard" types means that users may replace ApiClient with their desired accessor implementations. Including Json.NET types in Configuration will make this unusable for users who don't pull that type into their client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its possible to move it to the constructor. But everything is configurated inside the Configuration type but just not this? I think every C# developer use Newtonsoft.Json. Even if the ApiClient changes. When it moved to the constructor of the ApiClient , the class that wrap this must also use Newtonsoft.Json.
If you want to use this type just inside the ApiClient , we have to create a custom type and map everything. But this is not a good way.

/// <summary>
/// Gets the json serializer settings
/// </summary>
JsonSerializerSettings SerializerSettings { get; }
Copy link
Member

Choose a reason for hiding this comment

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

See previous comment about scoping this to ApiClient only.

/// <summary>
/// Gets the proxy
/// </summary>
WebProxy Proxy { get; }
Copy link
Member

Choose a reason for hiding this comment

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

Note: changing this interface is a breaking change for existing client consumers.
Also, formatting is off by 4 spaces too many here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this interface is just used from the Configuration ? And this class is also generated. Using this proxy is optional

Copy link
Member

Choose a reason for hiding this comment

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

Since 5.0 is released soon, I think the breaking change here will be fine for client release. I still think the JsonSerializerSettings should stay in ApiClient, however, because this isn't API configuration but an implementation detail of ApiClient. Since we allow for users to define their own ApiClients (and bring their own serializers), it doesn't make a lot of sense to put ApiClient implementation-specific details into the Configuration object. That is, this configuration object should refer to System namespaces only.

I'd be happy to resolve this in a separate commit.

@jimschubert
Copy link
Member

@PeterTriebe I've left a few comments. CircleCI has failed because you'll need to rebuild the project and run the relevant csharp-netcore scripts under ./bin to regenerate affected samples.

@PeterTriebe
Copy link
Contributor Author

@jimschubert I have run the scripts and pushed it after the run fails the first time. Hm. I can try it again

@wing328
Copy link
Member

wing328 commented Jan 13, 2020

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328 wing328 added this to the 4.2.3 milestone Jan 13, 2020
@wing328 wing328 modified the milestones: 4.2.3, 5.0.0, 4.3.0 Jan 31, 2020
@hacki11
Copy link
Contributor

hacki11 commented Feb 17, 2020

is the 4.2.3 milestone correct? does the release 4.2.3 contain this pull request?

@wing328 wing328 modified the milestones: 4.3.0, 4.3.1 Mar 27, 2020
@wing328 wing328 removed this from the 4.3.1 milestone May 6, 2020
@jimschubert jimschubert self-assigned this May 22, 2020
@jimschubert
Copy link
Member

@wing328 the author of this PR hasn't responded to the request to tie the commits to the GitHub profile, and the implementation still needs a little work to follow the client's patterns. Namely, some formatting needs to be fixed and the NewtonSoft settings should be moved out of the configuration object into the ApiClient implementation.

Is it acceptable to fix this via separate PR and merge with the author details as-is?

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