Skip to content

Commit

Permalink
Merge pull request #26 from macisamuele/maci-fix-multi-part-issue
Browse files Browse the repository at this point in the history
Fix multi part issue
  • Loading branch information
cortinico committed May 20, 2019
2 parents 838fe72 + 93a1f53 commit 67ba99a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {

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

/**
* Private method to propagate the `x-nullable` vendor config form the global definitions to the usage.
* Private method to propagate the `x-nullable` vendor extension form the global definitions to the usage.
*/
private fun propagateXNullableVendorExtension(
refProperty: RefProperty,
Expand Down Expand Up @@ -423,6 +423,13 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
return codegenModel.dataType
}

/**
* Determine if the swagger operation consumes mutipart content.
*/
private fun isMultipartOperation(operation: Operation?): Boolean {
return operation?.consumes?.any { it == "multipart/form-data" } ?: false
}

/**
* Convert Swagger Operation object to Codegen Operation object
*
Expand All @@ -446,6 +453,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
if (unsafeOperations.contains(operation?.operationId)) {
codegenOperation.vendorExtensions[X_UNSAFE_OPERATION] = true
}
codegenOperation.isMultipart = isMultipartOperation(operation)
return codegenOperation
}

Expand Down

0 comments on commit 67ba99a

Please sign in to comment.