Skip to content

Commit

Permalink
add extension for hashable in swift5 (#7300)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Aug 26, 2020
1 parent 98582d5 commit 11a674f
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public Swift5ClientCodegen() {
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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down Expand Up @@ -86,4 +90,4 @@
case {{name}}{{#vendorExtensions.x-codegen-escaped-property-name}} = "{{{baseName}}}"{{/vendorExtensions.x-codegen-escaped-property-name}}{{/allVars}}
}
{{/vendorExtensions.x-codegen-has-escaped-property-names}}{{/additionalPropertiesType}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ definitions:
xml:
name: Tag
Pet:
x-swift-hashable: true
type: object
required:
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

internal struct Pet: Codable {
internal struct Pet: Codable, Hashable {

internal enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

/** Model for testing model with \"_class\" property */

@objc public class ClassModel: NSObject, Codable {

public var _class: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

/** Must be named `File` for test. */

@objc public class File: NSObject, Codable {

/** Test capitalization */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

/** Model for testing model name starting with number */

@objc public class Model200Response: NSObject, Codable {

public var name: Int?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

/** Model for testing reserved words */

@objc public class Return: NSObject, Codable {

public var _return: Int?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Pet: Codable {
public struct Pet: Codable, Hashable {

public enum Status: String, Codable, CaseIterable {
case available = "available"
Expand Down

0 comments on commit 11a674f

Please sign in to comment.