Skip to content

Commit

Permalink
Fix param schema type parsing (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwini-desai authored Aug 8, 2020
1 parent 62a3a48 commit 3b78835
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions codegen/src/main/kotlin/apifi/helpers/Functions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fun toCamelCase(s: String): String = CaseUtils.toCamelCase(s, false, '_', '-', '

fun <T> Schema<T>.toCodeGenModel(name: String): CodegenModel = KotlinClientCodegen().fromModel(name, this)
fun <T> Schema<T>.toCodeGenModel(): CodegenModel = this.toCodeGenModel("any")
fun <T> Schema<T>.typeDeclaration(): String = KotlinClientCodegen().getTypeDeclaration(this)

fun String.toKotlinPoetType(): TypeName = toKotlinPoetType(emptyMap())

Expand Down
6 changes: 3 additions & 3 deletions codegen/src/main/kotlin/apifi/parser/PathsParser.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package apifi.parser

import apifi.helpers.toCamelCase
import apifi.helpers.toCodeGenModel
import apifi.helpers.toTitleCase
import apifi.models.*
import apifi.helpers.typeDeclaration
import apifi.models.Model
import apifi.parser.models.*
import io.swagger.v3.oas.models.PathItem
import io.swagger.v3.oas.models.Paths
Expand All @@ -14,7 +14,7 @@ object PathsParser {
return ParseResult(paths?.map { (endpoint, config) ->
val operations = config.readOperationsMap().map { (httpMethod, operation) ->
val params = operation.parameters?.map { param ->
Param(param.name, param.schema.toCodeGenModel().dataType, param.required, ParamType.fromString(param.`in`))
Param(param.name, param.schema.typeDeclaration(), param.required, ParamType.fromString(param.`in`))
} ?: emptyList()
val operationSpecifier = operationSpecifier(operation, httpMethod, endpoint)
val request = RequestBodyParser.parse(operation.requestBody, operationSpecifier)
Expand Down

0 comments on commit 3b78835

Please sign in to comment.