You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java code generated for request body for multi-part form data does not put the content of the files in request body, instead it places the file path and name in the request body.
WGET OpenAPI generator version 3.3.4 via instructions on Github README
OpenAPI yaml openapi-upload-files.yaml
openapi: 3.0.0info:
title: OpenApi file upload request bodyversion: "1.0.0"contact:
name: Walt Shandsemail: jshands@ucsc.edutags:
- name: upload_testdescription: test multipart uploadpaths:
/runs:
post:
summary: Upload an array of files.description: >- This endpoint uploads an array of files.operationId: UploadFilesresponses:
'200':
description: '''400':
description: The request is malformed.'401':
description: The request is unauthorized.'403':
description: The requester is not authorized to perform this action.'500':
description: An unexpected error occurred.tags:
- UploadFilesServicerequestBody:
content:
multipart/form-data:
schema:
type: objectproperties:
file_list:
type: arrayitems:
type: stringformat: binary
Build client from OpenApi yaml with OpenAPI generator
javac -cp <path to openapi generated client>/target/openapi-java-client-1.0.0.jar <path>/src/main/java/io/arrayoffiles/PostArrayOfFiles.java
Monitor POST requests in another terminal window
sudo tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
Run test program
java -debug -cp <path to PostArrayOfFiles class>/target/classes:<path to openapi generated client>target/*:<path to other needed jars>/target/lib/* io.arrayoffiles.PostArrayOfFiles
Produces this POST request body (seen in tcpdump window):
There should have been two bodies with Content-Disposition that included a 'filename="test<#>.txt" and the contents of the file
ApiClient.java creates a correct body only if the instance of the formParams Object is a File, but in the test case it is a List of Files and so the correct body is not created.
The text was updated successfully, but these errors were encountered:
Java code generated for request body for multi-part form data does not put the content of the files in request body, instead it places the file path and name in the request body.
WGET OpenAPI generator version 3.3.4 via instructions on Github README
OpenAPI yaml openapi-upload-files.yaml
Build client from OpenApi yaml with OpenAPI generator
Java class used for generation of POST request
Compile test program
Monitor POST requests in another terminal window
Run test program
Produces this POST request body (seen in tcpdump window):
There should have been two bodies with Content-Disposition that included a 'filename="test<#>.txt" and the contents of the file
ApiClient.java creates a correct body only if the instance of the formParams Object is a File, but in the test case it is a List of Files and so the correct body is not created.
The text was updated successfully, but these errors were encountered: