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
The rest client also supports request with mime-type multipart/form-data and, if the schema of the request body is known in advance, we can also automatically generate the models of the request bodies.
280
+
281
+
The rest client also supports request with mime-type multipart/form-data and, if the schema of the request body is known in advance, we can also automatically generate the models of the request
282
+
bodies.
281
283
282
284
You need to add the following additional dependency to your `pom.xml`:
For any multipart/form-data operation a model for the request body will be generated. Each part of the multipart is a field in this model that is annotated with the following annotations:
290
-
-`javax.ws.rs.FormParam`, where the value parameter denotes the part name,
295
+
296
+
-`javax.ws.rs.FormParam`, where the value parameter denotes the part name,
291
297
-`org.jboss.resteasy.annotations.providers.multipart.PartType`, where the parameter is the jax-rs MediaType of the part (see below for details),
292
-
- and, if the part contains a file, `org.jboss.resteasy.annotations.providers.multipart.PartFilename`, with a generated default parameter that will be passed as the fileName sub-header in the Content-Disposition header of the part.
298
+
- and, if the part contains a file, `org.jboss.resteasy.annotations.providers.multipart.PartFilename`, with a generated default parameter that will be passed as the fileName sub-header in the
299
+
Content-Disposition header of the part.
300
+
301
+
For example, the model for a request that requires a file, a string and some complex object will look like this:
293
302
294
-
For example, the model for a request that requires a file, a string and some complex object will look like this:
295
303
```java
296
304
publicclassMultipartBody {
297
305
@@ -311,33 +319,41 @@ public class MultipartBody {
311
319
```
312
320
313
321
Then in the client the `org.jboss.resteasy.annotations.providers.multipart.MultipartForm` annotation is added in front of the multipart parameter:
See [Quarkus - Using the REST Client with Multipart](https://quarkus.io/guides/rest-client-multipart) and the [RESTEasy JAX-RS specifications](https://docs.jboss.org/resteasy/docs/4.7.5.Final/userguide/html_single/index.html) for more details.
327
335
328
-
Importantly, if some multipart request bodies contain complex objects (i.e. non-primitives) you need to explicitly tell the Open API generator to create models for these objects by setting the `skip-form-model` property corresponding to your spec in the `application.properties` to `false`, e.g.:
336
+
See [Quarkus - Using the REST Client with Multipart](https://quarkus.io/guides/rest-client-multipart) and
337
+
the [RESTEasy JAX-RS specifications](https://docs.jboss.org/resteasy/docs/4.7.5.Final/userguide/html_single/index.html) for more details.
338
+
339
+
Importantly, if some multipart request bodies contain complex objects (i.e. non-primitives) you need to explicitly tell the Open API generator to create models for these objects by setting
340
+
the `skip-form-model` property corresponding to your spec in the `application.properties` to `false`, e.g.:
### Default content-types according to OpenAPI Specification and limitations
347
+
334
348
The [OAS 3.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#special-considerations-for-multipart-content) specifies the following default content-types for a multipart:
349
+
335
350
- If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain`
336
351
- If the property is complex, or an array of complex values, the default Content-Type is `application/json`
337
352
- If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream`
338
353
339
-
A different content-type may be defined in your api spec, but this is not yet supported in the code generation. Also, this "annotation-oriented" approach of RestEasy (i.e. using `@MultipartForm` to denote the multipart body parameter) does not seem to properly support the unmarshalling of arrays of the same type (e.g. array of files), in these cases it uses Content-Type equal to `application/json`.
340
-
354
+
A different content-type may be defined in your api spec, but this is not yet supported in the code generation. Also, this "annotation-oriented" approach of RestEasy (i.e. using `@MultipartForm` to
355
+
denote the multipart body parameter) does not seem to properly support the unmarshalling of arrays of the same type (e.g. array of files), in these cases it uses Content-Type equal
356
+
to `application/json`.
341
357
342
358
## Generating files via InputStream
343
359
@@ -347,6 +363,13 @@ saved locally in your project.
347
363
348
364
See the example implementation [here](test-utils/src/main/java/io/quarkiverse/openapi/generator/testutils/codegen/ClassPathPetstoreOpenApiSpecInputProvider.java)
349
365
366
+
## Skip Deprecated Attributes in Model classes
367
+
368
+
The domain objects are classes generated in the `model` package. These classes might have [deprecated attributes](https://spec.openapis.org/oas/v3.1.0#fixed-fields-9) in the Open API specification
369
+
file. By default, these attributes are generated. You can fine tune this behavior if the deprecated attributes should not be generated.
370
+
371
+
Use the property key `<base_package>.model.MyClass.generateDeprecated=false` to disable the deprecated attributes in the given model. For example `org.acme.weather.Country.generatedDeprecated=false`.
372
+
350
373
## Known Limitations
351
374
352
375
These are the known limitations of this pre-release version:
Copy file name to clipboardExpand all lines: deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/template/ModelConfigValueResolver.java
Copy file name to clipboardExpand all lines: deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/template/QuteTemplatingEngineAdapter.java
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ public QuteTemplatingEngineAdapter() {
Copy file name to clipboardExpand all lines: deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapperTest.java
0 commit comments