mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Merge branch 'master' of https://github.com/openapitools/openapi-generator
This commit is contained in:
commit
abfeb6e035
@ -683,6 +683,11 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
*/
|
||||
@Override
|
||||
public String toModelName(final String name) {
|
||||
// obtain the name from modelNameMapping directly if provided
|
||||
if (modelNameMapping.containsKey(name)) {
|
||||
return modelNameMapping.get(name);
|
||||
}
|
||||
|
||||
// memoization
|
||||
if (schemaKeyToModelNameCache.containsKey(name)) {
|
||||
return schemaKeyToModelNameCache.get(name);
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
internal protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
16
samples/client/petstore/swift5/validation/Package.resolved
Normal file
16
samples/client/petstore/swift5/validation/Package.resolved
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "AnyCodable",
|
||||
"repositoryURL": "https://github.com/Flight-School/AnyCodable",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "862808b2070cd908cb04f9aafe7de83d35f81b05",
|
||||
"version": "0.6.7"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
public protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
@ -560,9 +563,20 @@ private class FormDataEncoding: ParameterEncoding {
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
if #available(iOS 15, macOS 11, *) {
|
||||
#if canImport(UniformTypeIdentifiers)
|
||||
if let utType = UTType(filenameExtension: pathExtension) {
|
||||
return utType.preferredMIMEType ?? "application/octet-stream"
|
||||
}
|
||||
#else
|
||||
return "application/octet-stream"
|
||||
#endif
|
||||
} else {
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(),
|
||||
let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user