-
Notifications
You must be signed in to change notification settings - Fork 23
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
Update OpenAPI Spec & Merge Files API #139
Conversation
…m-for-request-and-response-bodies
…-bodies # Conflicts: # .codegen/_openapi_sha
…m-for-request-and-response-bodies
…m-for-request-and-response-bodies
…m-for-request-and-response-bodies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diff seems to be bigger than necessary just for the addition of request headers.
.codegen/impl.java.tmpl
Outdated
|
||
{{ define "headers" -}} | ||
Map<String, String> headers = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this results in the unnecessary diff and headers variable for literally every single method. surround it with if
and make sure there's no diff in the unaffected methods
Map<String, String> headers = new HashMap<>(); | |
{{if .FixedRequestHeaders}} | |
... what you have here | |
{{end}} |
.codegen/impl.java.tmpl
Outdated
{{- else}}{{template "type" .Response}} | ||
{{- end -}}{{else}}, Void{{end}}.class); | ||
{{end}} | ||
{{ template "headers" . -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{ template "headers" . -}} | |
{{- template "headers" . -}} |
to cut whitespace before
.codegen/impl.java.tmpl
Outdated
{{- else if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class, headers); | ||
{{- else if .Response.MapValue -}} return apiClient.getStringMap(path, {{ template "request-param" .}}, headers); | ||
{{- else if .IsResponseByteStream -}} | ||
InputStream response = {{ template "api-call" . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not returning InputStream
as a result type? it makes sense to return a wrapping response type only if there's more than one field in it, otherwise it's confusing.
.codegen/impl.java.tmpl
Outdated
{{ template "headers" . -}} | ||
{{ if not .Response -}} | ||
{{ template "api-call" . }} | ||
{{- else if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class, headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this cannot be solved with overloading?
{{- else if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class, headers); | |
{{- else if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class{{.HasRequestReaders}}, headers{{end}}); |
## Changes Query parameters are determined reflectively from request classes by scanning for fields with a QueryParam annotation. Serialization of query parameters is recursive in order to support complex types like the filter structures used for listing in the SQL query history service. This PR makes the following changes: 1. Terminate recursion when the request field is an enum. 2. When iterating through the request object's fields, skip any fields not annotated with QueryParam (but recursively, all fields do need to be serialized). 3. Rename the inner class from HeaderEntry to QueryParamPair (it represents query param pairs, not header entries). ## Tests Test for this change is dependent on other testing refactors that will be merged as part of #139.
@@ -84,8 +84,7 @@ private Response computeResponse(Request in, CloseableHttpResponse response) thr | |||
boolean streamResponse = | |||
in.getHeaders().containsKey("Accept") | |||
&& !APPLICATION_JSON.getMimeType().equals(in.getHeaders().get("Accept")) | |||
&& hs.containsKey("Content-Type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because header keys are not case-sensitive (esp. if response is HTTP 2.0, which enforces header keys to be lower case). In theory, the same check applies to request headers, but we know the case used because we control it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for going over the PR for review. LGTM
Changes
This PR adds recent changes from OpenAPI to the Java SDK. Notably, it adds support for the Files API. The integration test for this API can only be run in UC workspaces, so this PR also adds support for UC-only integration tests at the workspace- and account-level.
Tests