[documentcollector] Code generation: update services and models - #2045
[documentcollector] Code generation: update services and models#2045AdyenAutomationBot wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the auto-generated Java SDK client and models for the Cross-border Invoices API (documentcollector service). While the addition of these models and API endpoints is correct in scope, several critical issues were identified in the generated code. Specifically, the uploadCrossBorderInvoice method in DocumentsApi discards all of its parameters and forwards a null request, making document uploads impossible. Additionally, the static mapper in the JSON class is unsafely initialized inside a non-static constructor, which poses thread-safety risks and should be moved to a static block. Finally, a minor improvement is needed in AbstractOpenApiSchema to add a missing @Override annotation to the equals method.
| public DocumentUploadResponse uploadCrossBorderInvoice( | ||
| DocumentContext context, File _file, String merchantAccount) | ||
| throws ApiException, IOException { | ||
| return uploadCrossBorderInvoice(null); | ||
| } |
There was a problem hiding this comment.
The generated method uploadCrossBorderInvoice completely discards its parameters (context, _file, and merchantAccount) and forwards the call to uploadCrossBorderInvoice(null). This results in an empty request body (null) being sent to the /crossBorderInvoices endpoint, making it impossible to actually upload any documents using this method.\n\nPlease verify the OpenAPI specification or the generator templates to ensure that multipart form data or request body serialization is correctly configured and generated for this endpoint.
| private static ObjectMapper mapper; | ||
|
|
||
| private JSON() { | ||
| mapper = new ObjectMapper(); | ||
| mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | ||
| mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true); | ||
| mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
| mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); | ||
| mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); | ||
| mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); | ||
| mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); | ||
| mapper.registerModule(new JavaTimeModule()); | ||
| // Custom ByteSerializer | ||
| SimpleModule simpleModule = new SimpleModule(); | ||
| simpleModule.addSerializer(byte[].class, new ByteArraySerializer()); | ||
| simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer()); | ||
| mapper.registerModule(simpleModule); | ||
| } |
There was a problem hiding this comment.
The static field mapper is initialized inside the non-static constructor of the JSON class. If multiple instances of JSON are created (for example, by a JAX-RS container or via setDefault), the static mapper will be overwritten, which can lead to race conditions or unexpected configuration changes in a multi-threaded environment.\n\nIt is highly recommended to initialize the static mapper either directly at its declaration or within a static initializer block to ensure thread safety and prevent re-initialization.
private static final ObjectMapper mapper;\n\n static {\n mapper = new ObjectMapper();\n mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\n mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true);\n mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\n mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);\n mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);\n mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);\n mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);\n mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);\n mapper.registerModule(new JavaTimeModule());\n // Custom ByteSerializer\n SimpleModule simpleModule = new SimpleModule();\n simpleModule.addSerializer(byte[].class, new ByteArraySerializer());\n simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer());\n mapper.registerModule(simpleModule);\n }\n\n private JSON() {\n }| return o.toString().replace("\n", "\n "); | ||
| } | ||
|
|
||
| public boolean equals(Object o) { |
There was a problem hiding this comment.
The equals method overrides Object.equals but is missing the @Override annotation. Adding @Override is a best practice that improves readability and allows the compiler to catch errors if the method signature is accidentally changed.
| public boolean equals(Object o) { | |
| @Override\n public boolean equals(Object o) { |
|



This PR contains the automated changes for the
documentcollectorservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.