Skip to content

Commit

Permalink
KTOR-8064 Add media type for Yaml (#4600)
Browse files Browse the repository at this point in the history
  • Loading branch information
IRus authored Jan 14, 2025
1 parent c47dfda commit 9535a8e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions ktor-http/api/ktor-http.api
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public final class io/ktor/http/ContentType$Application {
public final fun getXlsx ()Lio/ktor/http/ContentType;
public final fun getXml ()Lio/ktor/http/ContentType;
public final fun getXml_Dtd ()Lio/ktor/http/ContentType;
public final fun getYaml ()Lio/ktor/http/ContentType;
public final fun getZip ()Lio/ktor/http/ContentType;
}

Expand Down
2 changes: 2 additions & 0 deletions ktor-http/api/ktor-http.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ final class io.ktor.http/ContentType : io.ktor.http/HeaderValueWithParameters {
final fun <get-Xml>(): io.ktor.http/ContentType // io.ktor.http/ContentType.Application.Xml.<get-Xml>|<get-Xml>(){}[0]
final val Xml_Dtd // io.ktor.http/ContentType.Application.Xml_Dtd|{}Xml_Dtd[0]
final fun <get-Xml_Dtd>(): io.ktor.http/ContentType // io.ktor.http/ContentType.Application.Xml_Dtd.<get-Xml_Dtd>|<get-Xml_Dtd>(){}[0]
final val Yaml // io.ktor.http/ContentType.Application.Yaml|{}Yaml[0]
final fun <get-Yaml>(): io.ktor.http/ContentType // io.ktor.http/ContentType.Application.Yaml.<get-Yaml>|<get-Yaml>(){}[0]
final val Zip // io.ktor.http/ContentType.Application.Zip|{}Zip[0]
final fun <get-Zip>(): io.ktor.http/ContentType // io.ktor.http/ContentType.Application.Zip.<get-Zip>|<get-Zip>(){}[0]
}
Expand Down
1 change: 1 addition & 0 deletions ktor-http/common/src/io/ktor/http/ContentTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public class ContentType private constructor(
public val Soap: ContentType = ContentType("application", "soap+xml")
public val Xml: ContentType = ContentType("application", "xml")
public val Xml_Dtd: ContentType = ContentType("application", "xml-dtd")
public val Yaml: ContentType = ContentType("application", "yaml")
public val Zip: ContentType = ContentType("application", "zip")
public val GZip: ContentType = ContentType("application", "gzip")

Expand Down
5 changes: 4 additions & 1 deletion ktor-http/common/src/io/ktor/http/Mimes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package io.ktor.http

import io.ktor.util.*

internal const val INITIAL_MIMES_LIST_SIZE: Int = 1212
internal const val INITIAL_MIMES_LIST_SIZE: Int = 1215

private val rawMimes: String
get() = """
Expand Down Expand Up @@ -688,6 +688,8 @@ application/xslt+xml,xslt
application/xspf+xml,xspf
application/xv+xml,mxml
application/yang,yang
application/yaml,yaml
application/x-yaml,yaml
application/yin+xml,yin
application/zip,war
audio/aac,aac
Expand Down Expand Up @@ -915,6 +917,7 @@ text/x-vcalendar,vcs
text/x-vcard,vcf
text/xml,xml
text/yaml,yaml
text/x-yaml,yaml
video/3gpp,3gp
video/3gpp2,3g2
video/animaflex,afl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SwaggerTest {

val response = client.get("/openapi/documentation.yaml")
val body = response.bodyAsText()
assertEquals("text/yaml; charset=UTF-8", response.contentType().toString())
assertEquals("application/yaml", response.contentType().toString())
assertEquals("hello:\n world".filter { it.isLetterOrDigit() }, body.filter { it.isLetterOrDigit() })
}

Expand Down

0 comments on commit 9535a8e

Please sign in to comment.