Skip to content

Commit e6d6f9a

Browse files
committed
Merge branch 'fix-multpart-body-issues' into release
2 parents 52b9d49 + 137551a commit e6d6f9a

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kotlin.code.style=official
33
# project id
44
projectGroupId=io.github.smiley4
55
projectArtifactIdBase=ktor-swagger-ui
6-
projectVersion=4.1.5
6+
projectVersion=4.1.6
77

88
# publishing information
99
projectNameBase=Ktor Swagger UI

ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContentBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ContentBuilder(
7272
props[part.name] = schemaContext.getSchema(part.type)
7373
}
7474
}
75+
schema.required = body.parts.filter { it.required }.map { it.name }
7576
}
7677
mediaType.encoding = buildMultipartEncoding(body)
7778
}

ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/schema/SchemaContextImpl.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class SchemaContextImpl(private val schemaConfig: SchemaConfigData) : SchemaCont
120120
is OpenApiMultipartBodyData -> {
121121
body.parts.forEach { part ->
122122
descriptors.add(part.type)
123+
part.headers.forEach { (_, header) ->
124+
header.type?.also { descriptors.add(it) }
125+
}
123126
}
124127
}
125128
}

ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiMultipartPartData.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import io.ktor.http.ContentType
88
data class OpenApiMultipartPartData(
99
val name: String,
1010
val type: TypeDescriptor,
11+
val required: Boolean,
1112
val mediaTypes: Set<ContentType>,
1213
val headers: Map<String, OpenApiHeaderData>,
1314
)

ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TypeDescriptor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ sealed interface TypeDescriptor
1515
*/
1616
class SwaggerTypeDescriptor(val schema: Schema<*>) : TypeDescriptor
1717

18-
1918
/**
2019
* Describes a type from a kotlin [KType]
2120
*/

ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiMultipartPart.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class OpenApiMultipartPart(
2424
val type: TypeDescriptor
2525
) {
2626

27+
/**
28+
* Whether this part is required
29+
*/
30+
var required: Boolean = false
31+
2732
/**
2833
* Specific content types for this part
2934
*/
@@ -83,6 +88,7 @@ class OpenApiMultipartPart(
8388
fun build() = OpenApiMultipartPartData(
8489
name = name,
8590
type = type,
91+
required = required,
8692
mediaTypes = mediaTypes.toSet(),
8793
headers = headers.mapValues { it.value.build() }
8894
)

0 commit comments

Comments
 (0)