Search code examples
javaswagger-codegen

How to disable swagger-codegen java.io.InputStream conversion


I got rests that return:

java.io.InputStream,
com.fasterxml.jackson.databind.JsonNode,
org.springframework.core.io.InputStreamRecource 

But in result swagger-codegen generated API, I got rests, that return:

productName.client.model.InputStream,
ErrorModelNamenamespacecomFasterxmlJacksonDatabindNameJsonNode,
productName.client.model.InputStreamResource

I can't ignore them by .swagger-codegen-ignore

And i think that replacing java.io.InputStream by byte[] is not good (how it described here). Cause stream has some pluses, such as exclusion of memory leaks.

What interesting, Swagger understand, that classes from springframework.http must not be converted. I got them all as original in generated API.

Is it possible to save java.io.InputStream and org.springframework.core.io.InputStreamRecource?


Solution

  • Done by

    java -jar swagger-codegen-cli-3.0.27.jar generate --import-mappings InputStreamResource=org.springframework.core.io.InputStreamResource,JsonNode=com.fasterxml.jackson.databind.JsonNode,InputStream=java.io.InputStream -DhideGenerationTimestamp=true -i "http://$CONTAINER_IP:8080/app_name/rest/v3/api-docs" -l java --library resttemplate -o app_name-api-client

    or through

    .swagger-codegen-ignore file by add /src/main/java/app_name/client/InputStreamResource