-
Notifications
You must be signed in to change notification settings - Fork 21
feat: [OpenAPI] Part 2: Testing Apache Client Support and some fixes. #1062
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
base: feat/openapi/refactor-apache-templates
Are you sure you want to change the base?
feat: [OpenAPI] Part 2: Testing Apache Client Support and some fixes. #1062
Conversation
…pi/test-apache-client-templates
- Hide response body from exception message - regenerate with formatting adjustments - Non-null response when return type is OpenApiResponse. - invokeAPI is nullable
- Make getter for basePath
…templates' into feat/openapi/test-apache-client-templates # Conflicts: # datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/genericreturntype/GenericReturnTypeTest.java
…r getter ignore behaviour
| * @throws OpenApiRequestException | ||
| * if an error occurs while attempting to invoke the API | ||
| */ | ||
| @Nonnull |
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 @Nonull annotaion is a lie. The same exists in Spring equivalent.
I am assuming this was intentional to not force handling possible null value at the caller. Still, would like some confirmation.
To add some details, invokeAPI() calls will return null when response body is empty or status is. 204
…pi/test-apache-client-templates
| { | ||
| return Stream | ||
| .of( | ||
| Arguments.of((Function<HttpDestination, Object>) ( des ) -> new TestSpringApi(des).testMethod()), |
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.
(Comment)
Cool solution!
| }); | ||
|
|
||
| // Always disable supportUrlQuery as it's not compatible with interface generation | ||
| result.put(SUPPORT_URL_QUERY, "false"); |
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.
(Question)
This looks surprising. Will this not result in a breaking change? What is this flag doing?
| //TODO: support byte[] for files? Do via review | ||
| // final byte[] result = sut.sodasDownloadIdGet(1L); | ||
| // assertThat(result).isNotNull(); | ||
| // assertThat(result).isEqualTo(binaryData); |
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.
(Minor)
We may need an additional unit test for that(?)
| @Test | ||
| void testPutPayload() | ||
| { | ||
| // TODO: discuss whether to ignore null on serialization? Do via review |
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.
(Minor)
I feel like this is a risky behavior change. While personally I would like that, I'm afraid that users may be affected unwillingly by that. Maybe we can instead come up with a convenience toggle/method somehow.
For comparison, the payload from legacy RestTemplate-based ("Spring") ApiClient:
expected = """
{
"name": "Cola",
"brand": "Coca-Cola",
"quantity": 100,
"packaging" : null,
"price": 1.5,
"id": 0
}
""";
Context
SAP/cloud-sdk-java-backlog#464.
Helpful Links:
In the previous PR, we introduced OpenAPI generator support for apache-httpclient template library, effectively making Spring options.
In this PR, there exists the test coverage for the new components equivalent to Spring.
Feature scope:
openapi-coreopenapi-api-apache-samplemoduleopenapi-generator<supportUrlQuery>false</supportUrlQuery>by hard coding it into the generatorDefinition of Done
Error handling created / updated & covered by the tests aboveDocumentation updatedRelease notes updated