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

Use kotlinx.serialization instead of moshi #136

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object PublishingVersions {
const val PLUGIN_VERSION = "1.4.1"
const val PLUGIN_GROUP = "com.yelp.codegen"
@Suppress("UNUSED")
const val PLUGIN_ARTIFACT = "plugin"
const val PLUGIN_VERSION = "1.4.1"
const val PLUGIN_GROUP = "com.yelp.codegen"
@Suppress("UNUSED")
const val PLUGIN_ARTIFACT = "plugin"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import io.swagger.models.Swagger

open class KotlinCoroutineGenerator : KotlinGenerator() {

init {
templateDir = "kotlin"
}
init {
templateDir = "kotlin"
}

override fun getName() = "kotlin-coroutines"
override fun getName() = "kotlin-coroutines"

override fun wrapResponseType(imports: MutableSet<String>, responsePrimitiveType: String) = responsePrimitiveType
override fun wrapResponseType(imports: MutableSet<String>, responsePrimitiveType: String) = responsePrimitiveType

override fun getNoResponseType(imports: MutableSet<String>) = "Unit"
override fun getNoResponseType(imports: MutableSet<String>) = "Unit"

/**
* Overriding the behavior of [KotlinGenerator] to make sure operations are rendered as `suspend fun` rather
* than just plain `fun`.
*/
override fun fromOperation(
path: String?,
httpMethod: String?,
operation: Operation?,
definitions: MutableMap<String, Model>?,
swagger: Swagger?
): CodegenOperation {
val codegenOperation = super.fromOperation(path, httpMethod, operation, definitions, swagger)
codegenOperation.vendorExtensions[X_FUNCTION_QUALIFIERS] = "suspend"
return codegenOperation
}
/**
* Overriding the behavior of [KotlinGenerator] to make sure operations are rendered as `suspend fun` rather
* than just plain `fun`.
*/
override fun fromOperation(
path: String?,
httpMethod: String?,
operation: Operation?,
definitions: MutableMap<String, Model>?,
swagger: Swagger?
): CodegenOperation {
val codegenOperation = super.fromOperation(path, httpMethod, operation, definitions, swagger)
codegenOperation.vendorExtensions[X_FUNCTION_QUALIFIERS] = "suspend"
return codegenOperation
}
}
Loading