-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Add operation level servers support for java okhttp-gson client #10925
Add operation level servers support for java okhttp-gson client #10925
Conversation
Add methods for hostIndex and customBaseUrl
if you dont specifically declare a custom base url using the set method then it uses the 1st server in the operation host index array if no custom url is set and the operation base path array is empty however, the call throws an exception
First checks to see if a custom url is provided If not, checks to see if operation level server is defined and uses the supplied host index (default 0) If neither is supplied, uses the ApiClient default base path
LGTM. We'll add a test or 2 later when we update the samples to use OAS 3.0 spec. |
Hi @wing328 / @ajrice6713 - this caused breaking changes in generated code (ApiClient::buildCall/buildRequest etc) - furthermore the necessary code migration is a bit odd because the new parameter for these methods is not documented in the generated javadoc.
|
Can you provide the error snippet of whats broken in the buildCall function? It wasnt intended to be breaking (and worked in my testing) 😢 |
Hi @ajrice6713, I'm referring to a "breaking" API change, not a bug in your code :-) |
@Philipp-Borchert-ISH very good question. From what I understand, a developer shouldn't be calling these Do you mind elaborating a bit more on your use cases that require calling these |
Hi @wing328, we're using them primarily in artificial test cases to generate "bad" requests to validate server side error handling in our APIs - so it's probably an edge case.
I guess this is a bit of a tricky situation - the generated clients the developers "should" be using are exposing getters/setters and a constructor including the ApiClient class, so right now it is not obvious to developers (both providing + consuming SDKs) that they should not actually use it. Other classes / interfaces in the same package - e.g. ApiCallback or ApiException - are essential to the generated API clients as well. I think it would be beneficial for the future to have a clear distinction between "this is public -> it's an API" vs. "this should not be public -> shouldn't be visible" (visible as in access modifier). Thx for the quick feedback btw! |
Add operation level server support for Java okhttp-gson http client
Closes #10847
At the API level - user can specify a custom base URL. If no custom base url is specified, the API selects the 1st path level server (if any), unless a different host index is specified. If no operation level servers are defined, the http request is built using the spec default server url.
PR checklist
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.
master
(5.3.0),6.0.x
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @nmuesch