Skip to content
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

Merged
merged 48 commits into from
Aug 28, 2023
Merged

Update OpenAPI Spec & Merge Files API #139

merged 48 commits into from
Aug 28, 2023

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Aug 18, 2023

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

  • New integration test for Files API to verify that it works as expected.

Copy link
Contributor

@nfx nfx left a 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.


{{ define "headers" -}}
Map<String, String> headers = new HashMap<>();
Copy link
Contributor

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

Suggested change
Map<String, String> headers = new HashMap<>();
{{if .FixedRequestHeaders}}
... what you have here
{{end}}

{{- else}}{{template "type" .Response}}
{{- end -}}{{else}}, Void{{end}}.class);
{{end}}
{{ template "headers" . -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{ template "headers" . -}}
{{- template "headers" . -}}

to cut whitespace before

{{- 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" . }}
Copy link
Contributor

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.

{{ template "headers" . -}}
{{ if not .Response -}}
{{ template "api-call" . }}
{{- else if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class, headers);
Copy link
Contributor

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?

Suggested change
{{- 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}});

github-merge-queue bot pushed a commit that referenced this pull request Aug 24, 2023
## 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.
@mgyucht mgyucht changed the title [WIP] Files openapi Update OpenAPI Spec & Merge Files API Aug 25, 2023
@mgyucht mgyucht marked this pull request as ready for review August 25, 2023 21:30
@@ -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")
Copy link
Contributor Author

@mgyucht mgyucht Aug 28, 2023

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.

@mgyucht mgyucht requested a review from tanmay-db August 28, 2023 13:13
Copy link
Contributor

@tanmay-db tanmay-db left a 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

@mgyucht mgyucht added this pull request to the merge queue Aug 28, 2023
Merged via the queue into main with commit c1dbcff Aug 28, 2023
9 checks passed
@mgyucht mgyucht deleted the files-openapi branch August 28, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants