File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Sources/OpenAPIKitCore/Shared
Tests/OpenAPIKitCoreTests Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ extension Shared.ContentType.Builtin: RawRepresentable {
305305 case . woff: return " font/woff "
306306 case . woff2: return " font/woff2 "
307307 case . xml: return " application/xml "
308- case . yaml: return " application/x- yaml "
308+ case . yaml: return " application/yaml "
309309 case . zip: return " application/zip "
310310
311311 case . anyApplication: return " application/* "
@@ -359,6 +359,7 @@ extension Shared.ContentType.Builtin: RawRepresentable {
359359 case " font/woff2 " : self = . woff2
360360 case " application/xml " : self = . xml
361361 case " application/x-yaml " : self = . yaml
362+ case " application/yaml " : self = . yaml
362363 case " application/zip " : self = . zip
363364
364365 case " application/* " : self = . anyApplication
Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ final class ContentTypeTests: XCTestCase {
6666 }
6767 }
6868
69+ func test_x_yaml( ) {
70+ // test that we support old x-yaml type but also prefer new official media type
71+ let type1 = Shared . ContentType. init ( rawValue: " application/yaml " )
72+ let type2 = Shared . ContentType. init ( rawValue: " application/x-yaml " )
73+
74+ XCTAssertEqual ( type1? . rawValue, " application/yaml " )
75+ XCTAssertEqual ( type1, . yaml)
76+ XCTAssertEqual ( type2? . rawValue, " application/yaml " )
77+ XCTAssertEqual ( type2, . yaml)
78+ }
79+
6980 func test_goodParam( ) {
7081 let type = Shared . ContentType. init ( rawValue: " text/html; charset=utf8 " )
7182 XCTAssertEqual ( type? . warnings. count, 0 )
You can’t perform that action at this time.
0 commit comments