Skip to content
Open
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
Expand Up @@ -384,6 +384,14 @@ public void setEnumPropertyNaming(final String enumPropertyNamingType) {
}
}

@Override
public String toExampleValue(Schema schema) {
if (schema.getExample() != null) {
return super.toExampleValue(schema);
}
return null;
}

/**
* returns the OpenAPI type for the property
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,24 +788,31 @@ public void useTargetOnInterfaceAnnotations() throws IOException {
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@Schema(example = \"null\", description = \"\")"
);
assertFileContains(
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:Schema(example = \"null\", description = \"\")"
);
assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:Schema(description = \"\")"
);
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@Schema(example = \"null\", requiredMode = Schema.RequiredMode.REQUIRED, description = \"\")"
);
assertFileContains(
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:Schema(example = \"null\", requiredMode = Schema.RequiredMode.REQUIRED, description = \"\")"
);
assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = \"\")"
);
}

@Test(description = "use get Annotation use-site target on kotlin interface attributes (swagger1)")
public void useTargetOnInterfaceAnnotationsWithSwagger1() throws IOException {
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
output.deleteOnExit();
String outputPath = output.getAbsolutePath().replace('\\', '/');

KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
Expand All @@ -823,18 +830,26 @@ public void useTargetOnInterfaceAnnotationsWithSwagger1() throws IOException {
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@ApiModelProperty(example = \"null\", value = \"\")"
);
assertFileContains(
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:ApiModelProperty(example = \"null\", value = \"\")"
);
assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:ApiModelProperty(value = \"\")"
);
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@ApiModelProperty(example = \"null\", required = true, value = \"\")"
);
assertFileContains(
assertFileNotContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:ApiModelProperty(example = \"null\", required = true, value = \"\")"
);
assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Animal.kt"),
"@get:ApiModelProperty(required = true, value = \"\")"
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class Category(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class ModelApiResponse(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("code")
@get:JsonProperty("code") val code: kotlin.Int? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("type")
@get:JsonProperty("type") val type: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class Order(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("petId")
@get:JsonProperty("petId") val petId: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("quantity")
@get:JsonProperty("quantity") val quantity: kotlin.Int? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("shipDate")
@get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,

@Schema(example = "null", description = "Order Status")
@Schema(description = "Order Status")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("status")
@get:JsonProperty("status") val status: Order.Status? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("complete")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ data class Pet(
@param:JsonProperty("name")
@get:JsonProperty("name", required = true) val name: kotlin.String,

@Schema(example = "null", required = true, description = "")
@Schema(required = true, description = "")
@param:JsonProperty("photoUrls")
@get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@field:Valid
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("category")
@get:JsonProperty("category") val category: Category? = null,

@field:Valid
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("tags")
@get:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,

@Schema(example = "null", description = "pet status in the store")
@Schema(description = "pet status in the store")
@Deprecated(message = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class Tag(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,49 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class User(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("username")
@get:JsonProperty("username") val username: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("firstName")
@get:JsonProperty("firstName") val firstName: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("lastName")
@get:JsonProperty("lastName") val lastName: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("email")
@get:JsonProperty("email") val email: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("password")
@get:JsonProperty("password") val password: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("phone")
@get:JsonProperty("phone") val phone: kotlin.String? = null,

@Schema(example = "null", description = "User Status")
@Schema(description = "User Status")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("userStatus")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class Category(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class ModelApiResponse(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("code")
@get:JsonProperty("code") val code: kotlin.Int? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("type")
@get:JsonProperty("type") val type: kotlin.String? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@ import io.swagger.v3.oas.annotations.media.Schema
*/
data class Order(

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("petId")
@get:JsonProperty("petId") val petId: kotlin.Long? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("quantity")
@get:JsonProperty("quantity") val quantity: kotlin.Int? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("shipDate")
@get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,

@Schema(example = "null", description = "Order Status")
@Schema(description = "Order Status")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("status")
@get:JsonProperty("status") val status: Order.Status? = null,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("complete")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ data class Pet(
@param:JsonProperty("name")
@get:JsonProperty("name", required = true) val name: kotlin.String,

@Schema(example = "null", required = true, description = "")
@Schema(required = true, description = "")
@param:JsonProperty("photoUrls")
@get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,

@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("id")
@get:JsonProperty("id") val id: kotlin.Long? = null,

@field:Valid
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("category")
@get:JsonProperty("category") val category: Category? = null,

@field:Valid
@Schema(example = "null", description = "")
@Schema(description = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
@param:JsonProperty("tags")
@get:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,

@Schema(example = "null", description = "pet status in the store")
@Schema(description = "pet status in the store")
@Deprecated(message = "")
@field:JsonInclude(JsonInclude.Include.NON_NULL)
@field:JsonSetter(nulls = Nulls.SKIP)
Expand Down
Loading
Loading