Skip to content

Commit

Permalink
[297]Remove implicit mapping when an explicit is present in the spec (#…
Browse files Browse the repository at this point in the history
…298)

* [297]Remove implicit mapping when an explicit is present in the spec

* changelog
  • Loading branch information
JanC authored Mar 31, 2022
1 parent a6fd379 commit 6e0f18c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Fixed
- Fixed compilation with Xcode 13 #282 @sroebert
- Fixed duplicated switch cases when using explicit mappings in oneOf discriminator #297 @JanC

### Changed
- Improved `CodeFormatter` efficiency #272 @zntfdr
Expand Down
1 change: 1 addition & 0 deletions Sources/SwagGenKit/CodeFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public class CodeFormatter {
for (key, value) in discriminatorMapping {
// TODO: could reference another spec
let reference = Reference<Schema>(value)
mapping.removeValue(forKey: reference.name)
mapping[key] = getReferenceContext(reference)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public enum SingleAnimal: Codable, Equatable {
let container = try decoder.container(keyedBy: StringCodingKey.self)
let discriminator: String = try container.decode("type")
switch discriminator {
case "Cat":
self = .cat(try Cat(from: decoder))
case "Dog":
self = .dog(try Dog(from: decoder))
case "cat":
self = .cat(try Cat(from: decoder))
case "dog":
Expand Down

0 comments on commit 6e0f18c

Please sign in to comment.