Skip to content

Commit

Permalink
Restore generation of inline types for all of (#267) (#269)
Browse files Browse the repository at this point in the history
* Restore generation of inline types for all of (#267)

* Update change log with fix for issue #267
  • Loading branch information
nicholascross authored Apr 12, 2021
1 parent 671215e commit c90058e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixed
- Fixed sporadic crashes due to malformed URLs #268 @marcelvoss
- Fixed generation of inline types for `allOf` #267

## 4.4.0

Expand Down
2 changes: 2 additions & 0 deletions Sources/SwagGenKit/SwaggerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ extension Schema {
case let .group(group):
if group.discriminator != nil {
return self
} else if case .all = group.type {
return self
}
default: break
}
Expand Down
40 changes: 40 additions & 0 deletions Specs/TestSpec/generated/Swift/Sources/Models/Zoo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,46 @@ public class Zoo: APIModel {

public var schemaAnimals: [SingleAnimal]?

public class AllOfDog: Dog {

public override init(animal: String? = nil, barks: Bool? = nil) {
super.init(animal: animal, barks: barks)
}

public required init(from decoder: Decoder) throws {
try super.init(from: decoder)
}

public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}

override public func isEqual(to object: Any?) -> Bool {
guard object is AllOfDog else { return false }
return super.isEqual(to: object)
}
}

public class InlineAnimal: Animal {

public override init(animal: String? = nil) {
super.init(animal: animal)
}

public required init(from decoder: Decoder) throws {
try super.init(from: decoder)
}

public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}

override public func isEqual(to object: Any?) -> Bool {
guard object is InlineAnimal else { return false }
return super.isEqual(to: object)
}
}

public enum InlineAnimals: Codable, Equatable {
case cat(Cat)
case dog(Dog)
Expand Down

0 comments on commit c90058e

Please sign in to comment.