-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Java][jaxrs-spec] Codegen creates invalid code for multipart/form-data for quarkus #7994
Comments
hey @M-Landwehr, did you find a way to work around this? we're facing the exact same issue, also tried a couple of other generators but didn't get lucky so far...btw still present in 5.1.0 :-/ |
Any news on the issue, I am facing the same issue. Any work-around ? |
Same for me :( |
Same for me. Tried to use a custom ParamConverter (see https://resteasy.dev/2021/04/05/blog-ParamConverter-with-Quarkus/), without success. |
I "solved" it by modifying the mustache template files. In
In And in |
@fsiegrist package example
import java.io.ByteArrayInputStream
import java.io.InputStream
import java.nio.charset.StandardCharsets
import javax.ws.rs.ext.ParamConverter
import javax.ws.rs.ext.Provider
@Provider
class FileConverterProvider: ParamConverter<InputStream> {
override fun toString(value: InputStream): String {
return String(value.readAllBytes(), StandardCharsets.UTF_8)
}
override fun fromString(value: String): InputStream {
return ByteArrayInputStream(value.toByteArray())
}
} package example
import java.io.InputStream
import java.lang.reflect.Type
import javax.ws.rs.ext.ParamConverter
import javax.ws.rs.ext.ParamConverterProvider
import javax.ws.rs.ext.Provider
@Provider
class FileParamConverterProvider: ParamConverterProvider {
override fun <T : Any?> getConverter(
rawType: Class<T>?,
genericType: Type?,
annotations: Array<out Annotation>?
): ParamConverter<T>? {
return if (rawType!!.isAssignableFrom(InputStream::class.java)) {
(FileConverterProvider() as ParamConverter<T>?)!!
} else null
}
} |
@fsiegrist thanks for suggesting custom converter, it worked for me below is the java code
|
Description
When creating Java code from a openapi.yml for quakus, the resulting code does not work:
RESTEASY003875: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.FormParam("file") on public abstract void org.openapitools.api.UploadApi.uploadPost(java.io.InputStream,java.lang.String) for basetype: java.io.InputStream
Quarkus cannot handle the geneated method signature of the Rest-resource-class:
(Additionally, no validation annotations are created!)
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
Quarkus-Version: 1.9.2.Final
Steps to reproduce
mvnw package quarkus:dev
mvnw package quarkus:dev
Alternatively simply generate java code from the openapi.yml above using the jaxrs-spec generator and the quarkus library
Related issues/PRs
Suggest a fix/enhancement
The model-class is created but is not used in this case. (althogh is has
@JsonProperty
annotations insteadod the@FormParam
annotationsA possible fix would be to
multipart/form-data
request:@FormParam
public void uploadPost(@MultipartForm @Valid MultipartData data) {}
(see https://quarkus.io/guides/rest-client-multipart)
The text was updated successfully, but these errors were encountered: