Насколько я понял, openapi-генератор может получить файл и ответить файлом, если в файле yaml объявлено следующее:
Код: Выделить всё
/processfile:
post:
summary: Processes a file containing data according to the ruleset specified.
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
ruleset:
type: string
description: Ruleset to use for processing. Use the ruleset name as specified in the ruleset properties file.
file:
description: File to be processed.
type: string
format: binary
responses:
'200':
description: The tokenized data.
content:
application/octet-stream:
schema:
type: string
format: binary
'400':
description: bad input parameter
И сервер весенней загрузки, и клиент работают нормально, и во время модульных тестов они работают так, как ожидалось.
Однако, когда я объединяю их в интеграционном тесте, отправляю CSV-файл в вышеупомянутый API. Я получаю следующую ошибку:
Код: Выделить всё
org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.io.File] and content type [text/csv]
Код: Выделить всё
@Test
public void testCSVDatasetProcess() {
String inputFileName = "MOCK_DATA.csv";
String ruleset = "rulesetforcsv";
File inputFile = new File("src/test/resources/datafiles/" + inputFileName);
// process
File response = api.processfilePost(ruleset,inputFile);
}
После этого: https://community.smartbear.com/t5/Swag ... d-p/224501. Мне удалось заставить его работать, изменив YAML следующим образом:
Код: Выделить всё
/processfile:
post:
summary: Processes a file containing data according to the ruleset specified.
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
ruleset:
type: string
description: Ruleset to use for processing. Use the ruleset name as specified in the ruleset properties file.
file:
description: File to be processed.
type: string
format: binary
responses:
'200':
description: The tokenized data.
content:
application/octet-stream:
schema:
type: string
format: byte
Подробнее здесь: [url]https://stackoverflow.com/questions/74191632/openapi-generator-spring-boot-and-client-post-and-receive-file[/url]
Мобильная версия