feat: [OpenAPI] ResponseMetadataListener with case insensitive header map#1070
feat: [OpenAPI] ResponseMetadataListener with case insensitive header map#1070
ResponseMetadataListener with case insensitive header map#1070Conversation
This reverts commit 888bc4d.
- models only
- formatting - add api classes
- no more shared client in *Api.java instances
… apiclient package
- *Api.invoke method bugged and unused
- Remove debugging, connectionTimeout, defaultHeaderMap, defaultCookieMap - add TODOs - public setBasePath - Remove addDefaultHeader, setUserAgent,
- Make as manny methods static - Remove deprecated getStatusCode and getResponseHeaders - public parameterToPairs
- Make as many methods static - rename ApiClientResponseHandler to DefaultApiResponseHandler - finish up ApiClient todos
…st-apache-client-templates # Conflicts: # datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/api.mustache
…st-apache-client-templates # Conflicts: # datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/api.mustache
…#1062) Moving to single larger PR (sorry), because its getting difficult to sync changes across. Both PRs have been thoroughly review at this point.
…sponse-status-and-header # Conflicts: # datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/operationBody.mustache # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodaApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodasApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/DefaultApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/api/AwesomeSodaApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/api/AwesomeSodasApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/api/DefaultApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/api/DefaultApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/inlineobject-schemas-enabled/output/com/sap/cloud/sdk/services/inlineobject/api/DefaultApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/partial-generation/output/com/sap/cloud/sdk/services/builder/api/DefaultApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/OrdersApi.java # datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorApacheIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/SodasApi.java
# Conflicts: # datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiClient.java # datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/DefaultApiResponseHandler.java # datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/OpenApiResponse.java
| OpenApiResponse( final int statusCode, @Nonnull final Map<String, List<String>> headers ) | ||
| { | ||
| this.statusCode = statusCode; | ||
| this.headers = Map.copyOf(headers); |
There was a problem hiding this comment.
Map.copy() doesn't return a TreeMap and therefore removes the nice case insensitive matching of headers. Instead I opted to make the treeMap unmodifiable at creation site with Collections.unmodifiableMap()
| @FunctionalInterface | ||
| public interface ResponseMetadataListener | ||
| { | ||
| void onResponse( OpenApiResponse response ); |
There was a problem hiding this comment.
I could create a new class OpenApiResponseMetadata or similar instead of re-using or maybe even abusing OpenApiResponse class. What do you think?
|
SAP employees are expected to use their SAP-email address for commits related to their work. Our compliance check has detected usage of an email other than a SAP one by a SAP employee. Please update your pull request accordingly. If you think this is wrong or need any assistance, please contact ospo@sap.com. |
| * @since 5.25.0 | ||
| */ | ||
| @FunctionalInterface | ||
| public interface ResponseMetadataListener |
There was a problem hiding this comment.
(Minor/Nitpick)
ResponseMetadataListener isn't very easy name.
What would you think of OpenApiResponseListener?
newtork
left a comment
There was a problem hiding this comment.
Apart from minor question regarding naming: looks good!
|
|
||
| @With | ||
| private final ResponseMetadataListener responseMetadataListener; | ||
| private final OpenApiResponseListener responseMetadataListener; |
There was a problem hiding this comment.
(Very Minor/Question)
Would it make sense to also rename the variable to openApiResponseListener to make it more consistent? (Same in DefaultApiResponseHandler.)
|
|
||
| @With | ||
| private final ResponseMetadataListener responseMetadataListener; | ||
| private final OpenApiResponseListener openApiResponseListener; |
There was a problem hiding this comment.
(Minor)
Could we add the @Beta annotation here?
While I'm okay with current state, I feel like having options in the future would be nice:
- rename it, e.g. to
withResponseListener - extend interface API, e.g. with HttpResponse reference, settings for error handling
Context
SAP/cloud-sdk-java-backlog#464.
Feature scope:
ResponseMetadataListenerthat acceptsOpenApiResponseobject which includes the metadataDefinition of Done
Error handling created / updated & covered by the tests aboveDocumentation updatedRelease notes updated