add extension for hashable in swift5 (#7300)

This commit is contained in:
William Cheng 2020-08-26 19:29:29 +08:00 committed by GitHub
parent 98582d5780
commit 11a674f248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 19 additions and 18 deletions

View File

@ -197,6 +197,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("array", "Array");
typeMapping.put("List", "Array");
typeMapping.put("map", "Dictionary");
typeMapping.put("set", "Set");
typeMapping.put("date", "Date");
typeMapping.put("Date", "Date");
typeMapping.put("DateTime", "Date");

View File

@ -1,5 +1,9 @@
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct {{classname}}: Codable { {{/objcCompatible}}
{{#objcCompatible}}@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable { {{/objcCompatible}}
{{^objcCompatible}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct {{classname}}: Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
{{/objcCompatible}}
{{#objcCompatible}}
@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
{{/objcCompatible}}
{{#allVars}}
{{#isEnum}}

View File

@ -1134,6 +1134,7 @@ definitions:
xml:
name: Tag
Pet:
x-swift-hashable: true
type: object
required:
- name

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
internal struct Pet: Codable {
internal struct Pet: Codable, Hashable {
internal enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -8,7 +8,6 @@
import Foundation
/** Model for testing model with \"_class\" property */
@objc public class ClassModel: NSObject, Codable {
public var _class: String?

View File

@ -8,7 +8,6 @@
import Foundation
/** Must be named `File` for test. */
@objc public class File: NSObject, Codable {
/** Test capitalization */

View File

@ -8,7 +8,6 @@
import Foundation
/** Model for testing model name starting with number */
@objc public class Model200Response: NSObject, Codable {
public var name: Int?

View File

@ -8,7 +8,6 @@
import Foundation
/** Model for testing model name same as property name */
@objc public class Name: NSObject, Codable {
public var name: Int

View File

@ -7,7 +7,7 @@
import Foundation
@objc public class Pet: NSObject, Codable {
@objc public class Pet: NSObject, Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -8,7 +8,6 @@
import Foundation
/** Model for testing reserved words */
@objc public class Return: NSObject, Codable {
public var _return: Int?

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"

View File

@ -7,7 +7,7 @@
import Foundation
public struct Pet: Codable {
public struct Pet: Codable, Hashable {
public enum Status: String, Codable, CaseIterable {
case available = "available"