Skip to content

Commit 67ba99a

Browse files
authored
Merge pull request #26 from macisamuele/maci-fix-multi-part-issue
Fix multi part issue
2 parents 838fe72 + 93a1f53 commit 67ba99a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
259259

260260
/**
261261
* Private method to investigate all the properties of a models, filter only the [RefProperty] and eventually
262-
* propagate the `x-nullable` vendor config.
262+
* propagate the `x-nullable` vendor extension.
263263
*/
264264
private fun propagateXNullableToProperties(model: Model, allDefinitions: MutableMap<String, Model>) {
265265
model.properties
@@ -269,7 +269,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
269269
}
270270

271271
/**
272-
* Private method to propagate the `x-nullable` vendor config form the global definitions to the usage.
272+
* Private method to propagate the `x-nullable` vendor extension form the global definitions to the usage.
273273
*/
274274
private fun propagateXNullableVendorExtension(
275275
refProperty: RefProperty,
@@ -423,6 +423,13 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
423423
return codegenModel.dataType
424424
}
425425

426+
/**
427+
* Determine if the swagger operation consumes mutipart content.
428+
*/
429+
private fun isMultipartOperation(operation: Operation?): Boolean {
430+
return operation?.consumes?.any { it == "multipart/form-data" } ?: false
431+
}
432+
426433
/**
427434
* Convert Swagger Operation object to Codegen Operation object
428435
*
@@ -446,6 +453,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
446453
if (unsafeOperations.contains(operation?.operationId)) {
447454
codegenOperation.vendorExtensions[X_UNSAFE_OPERATION] = true
448455
}
456+
codegenOperation.isMultipart = isMultipartOperation(operation)
449457
return codegenOperation
450458
}
451459

0 commit comments

Comments
 (0)