Skip to content

Add CaseIterable conformance for string, int enums #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ enum Constants {
static let baseConformanceInteger: String = "Int"

/// The types that every enum conforms to.
static let conformances: [String] = ["Codable", "Hashable", "Sendable"]
static let conformances: [String] = ["Codable", "Hashable", "Sendable", "CaseIterable"]
}

/// Constants related to generated oneOf enums.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public enum Components {
/// Kind of pet
///
/// - Remark: Generated from `#/components/schemas/PetKind`.
@frozen public enum PetKind: String, Codable, Hashable, Sendable {
@frozen public enum PetKind: String, Codable, Hashable, Sendable, CaseIterable {
case cat = "cat"
case dog = "dog"
case ELEPHANT = "ELEPHANT"
Expand Down Expand Up @@ -492,7 +492,7 @@ public enum Components {
/// - Remark: Generated from `#/components/schemas/PetFeeding`.
public struct PetFeeding: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/PetFeeding/schedule`.
@frozen public enum schedulePayload: String, Codable, Hashable, Sendable {
@frozen public enum schedulePayload: String, Codable, Hashable, Sendable, CaseIterable {
case hourly = "hourly"
case daily = "daily"
case weekly = "weekly"
Expand Down Expand Up @@ -1491,7 +1491,7 @@ public enum Components {
/// - Remark: Generated from `#/components/requestBodies/MultipartUploadTypedRequest/multipartForm/log/headers`.
public struct Headers: Sendable, Hashable {
/// - Remark: Generated from `#/components/requestBodies/MultipartUploadTypedRequest/multipartForm/log/headers/x-log-type`.
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable {
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable, CaseIterable {
case structured = "structured"
case unstructured = "unstructured"
}
Expand Down Expand Up @@ -1645,7 +1645,7 @@ public enum Components {
/// - Remark: Generated from `#/components/responses/MultipartDownloadTypedResponse/content/multipartForm/log/headers`.
public struct Headers: Sendable, Hashable {
/// - Remark: Generated from `#/components/responses/MultipartDownloadTypedResponse/content/multipartForm/log/headers/x-log-type`.
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable {
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable, CaseIterable {
case structured = "structured"
case unstructured = "unstructured"
}
Expand Down Expand Up @@ -1773,7 +1773,7 @@ public enum Operations {
/// - Remark: Generated from `#/paths/pets/GET/query/limit`.
public var limit: Swift.Int32?
/// - Remark: Generated from `#/paths/pets/GET/query/habitat`.
@frozen public enum habitatPayload: String, Codable, Hashable, Sendable {
@frozen public enum habitatPayload: String, Codable, Hashable, Sendable, CaseIterable {
case water = "water"
case land = "land"
case air = "air"
Expand All @@ -1782,7 +1782,7 @@ public enum Operations {
/// - Remark: Generated from `#/paths/pets/GET/query/habitat`.
public var habitat: Operations.listPets.Input.Query.habitatPayload?
/// - Remark: Generated from `#/paths/pets/GET/query/feedsPayload`.
@frozen public enum feedsPayloadPayload: String, Codable, Hashable, Sendable {
@frozen public enum feedsPayloadPayload: String, Codable, Hashable, Sendable, CaseIterable {
case omnivore = "omnivore"
case carnivore = "carnivore"
case herbivore = "herbivore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
""",
"""
public enum Schemas {
@frozen public enum MyEnum: String, Codable, Hashable, Sendable {
@frozen public enum MyEnum: String, Codable, Hashable, Sendable, CaseIterable {
case one = "one"
case _empty = ""
case _dollar_tart = "$tart"
Expand All @@ -1213,7 +1213,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
""",
"""
public enum Schemas {
@frozen public enum MyEnum: Int, Codable, Hashable, Sendable {
@frozen public enum MyEnum: Int, Codable, Hashable, Sendable, CaseIterable {
case _0 = 0
case _10 = 10
case _20 = 20
Expand All @@ -1238,7 +1238,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
"""
public enum Schemas {
public struct MyOpenEnum: Codable, Hashable, Sendable {
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable {
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable, CaseIterable {
case one = "one"
case two = "two"
}
Expand Down Expand Up @@ -1928,7 +1928,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
public enum Responses {
public struct BadRequest: Sendable, Hashable {
public struct Headers: Sendable, Hashable {
@frozen public enum X_hyphen_ReasonPayload: String, Codable, Hashable, Sendable {
@frozen public enum X_hyphen_ReasonPayload: String, Codable, Hashable, Sendable, CaseIterable {
case badLuck = "badLuck"
}
public var X_hyphen_Reason: Components.Responses.BadRequest.Headers.X_hyphen_ReasonPayload?
Expand Down Expand Up @@ -2118,7 +2118,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
@frozen public enum multipartFormPayload: Sendable, Hashable {
public struct logPayload: Sendable, Hashable {
public struct Headers: Sendable, Hashable {
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable {
@frozen public enum x_hyphen_log_hyphen_typePayload: String, Codable, Hashable, Sendable, CaseIterable {
case structured = "structured"
case unstructured = "unstructured"
}
Expand Down