Skip to content

csharp-netcore: Add HttpClient support - #8328

Merged
wing328 merged 3 commits into
OpenAPITools:csharp-netcore-httpclientfrom
devhl-labs:csharp-netcore-httpclient
Jan 5, 2021
Merged

csharp-netcore: Add HttpClient support#8328
wing328 merged 3 commits into
OpenAPITools:csharp-netcore-httpclientfrom
devhl-labs:csharp-netcore-httpclient

Conversation

@devhl-labs

@devhl-labs devhl-labs commented Jan 5, 2021

Copy link
Copy Markdown
Contributor

This is the beginning changes to move to HttpClient. It was working for my use case before I made the ApiException generic. At the moment it requires some post processing to replace ???? to ? and ??? to ?. This can be appended to the powershell script that begins the creation process in the first place. If this is good, then there is a lot of work to be done.

#6800
#5375

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

@devhl-labs thanks for this. What about adding the library option and let users choose which HTTP libraries to use? That's something we've already done in a few other generators, e.g. java, ruby.

@devhl-labs

Copy link
Copy Markdown
Contributor Author

There is no interface on HttpClient so it's hard for me to imagine how to do that gracefully. Plus HttpClient is very versatile. Even in the RestSharp library people are asking for it to use HttpClient, though it doesn't look like it will happen.

@devhl-labs

Copy link
Copy Markdown
Contributor Author

Also I'm guessing the changes I'm made would lead toward a mass rewrite, scrapping almost everything. That's why I put this pr here before I do such a thing. I doubt I'd migrate all the supported features since I only use a small subset.

@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

I saw the changes you made and we can easily support those via library option (which uses a new set of mustache templates) instead of using {{#isHttpLibrary}} .... {{/isHttpLibrary}} to handle the logic in all the existing template.

I'll file a PR to add the library option and we can merge this one into that one to continue the work.

@devhl-labs

Copy link
Copy Markdown
Contributor Author

Oh like a set of mustache files for RestSharp and a whole other set for HttpClient? Yes that would be ideal as it wouldn't break for existing users.

@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

Right. I'll try to file the PR in the afternoon and keep you posted.

@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

And thanks for starting the work on this. Much appreciated.

@wing328
wing328 changed the base branch from master to csharp-netcore-httpclient January 5, 2021 07:07
@wing328 wing328 added this to the 5.0.1 milestone Jan 5, 2021
@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

I'll merge this into the branch csharp-netcore-httpclient to make it easier to collaborate on adding HttpClient support.

@wing328
wing328 merged commit 64f533a into OpenAPITools:csharp-netcore-httpclient Jan 5, 2021
@wing328

wing328 commented Jan 5, 2021

Copy link
Copy Markdown
Member

I've added the library option (httpclient) in the branch. Please have a look at #8331 and let me know if you've any question.

@wing328 wing328 changed the title [WIP] csharp-netcore HttpClient csharp-netcore: Add HttpClient support Feb 3, 2021
@wing328 wing328 modified the milestone: 5.0.1 Feb 3, 2021
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.

2 participants