forked from loafle/openapi-generator-original
[BUG] [KOTLIN] Fix default value generation for Kotlin Strings (#5776)
* fix default value generation for kotlin
* add updated pet templates
* Revert "add updated pet templates"
This reverts commit 7e8168ad
* regen pet store projects code
This commit is contained in:
@@ -940,7 +940,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return "'" + p.getDefault() + "'";
|
||||
return "\"" + p.getDefault() + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
4.2.3-SNAPSHOT
|
||||
4.3.1-SNAPSHOT
|
||||
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo1.maven.org/maven2") }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.0.M3")
|
||||
@@ -15,7 +15,7 @@ version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo1.maven.org/maven2") }
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
@@ -48,7 +48,7 @@ dependencies {
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo1.maven.org/maven2") }
|
||||
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||
maven { url = uri("https://repo.spring.io/milestone") }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.springframework.web.context.request.NativeWebRequest
|
||||
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
import java.io.IOException
|
||||
|
||||
object ApiUtil {
|
||||
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
|
||||
try {
|
||||
val res = req.getNativeResponse(HttpServletResponse::class.java)
|
||||
res.setCharacterEncoding("UTF-8")
|
||||
res.addHeader("Content-Type", contentType)
|
||||
res.getWriter().print(example)
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Category (
|
||||
data class Category(
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") var id: kotlin.Long? = null,
|
||||
|
||||
@@ -17,7 +17,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param type
|
||||
* @param message
|
||||
*/
|
||||
data class ModelApiResponse (
|
||||
data class ModelApiResponse(
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("code") var code: kotlin.Int? = null,
|
||||
|
||||
@@ -21,7 +21,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param status Order Status
|
||||
* @param complete
|
||||
*/
|
||||
data class Order (
|
||||
data class Order(
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") var id: kotlin.Long? = null,
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param tags
|
||||
* @param status pet status in the store
|
||||
*/
|
||||
data class Pet (
|
||||
data class Pet(
|
||||
|
||||
@get:NotNull
|
||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||
|
||||
@@ -16,7 +16,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Tag (
|
||||
data class Tag(
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") var id: kotlin.Long? = null,
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.swagger.annotations.ApiModelProperty
|
||||
* @param phone
|
||||
* @param userStatus User Status
|
||||
*/
|
||||
data class User (
|
||||
data class User(
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") var id: kotlin.Long? = null,
|
||||
|
||||
@@ -1 +1 @@
|
||||
4.2.1-SNAPSHOT
|
||||
4.3.1-SNAPSHOT
|
||||
@@ -20,10 +20,10 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
* @param id
|
||||
* @param category
|
||||
* @param name
|
||||
* @param photoUrls
|
||||
* @param id
|
||||
* @param category
|
||||
* @param tags
|
||||
* @param status pet status in the store
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user