Skip to content
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

Fix multi part issue #26

Merged
merged 3 commits into from
May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -206,7 +206,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 @@ -216,7 +216,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 @@ -370,6 +370,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 @@ -393,6 +400,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