Skip to content

Commit 6a6ddf8

Browse files
authored
fix: Correct data type of date-formatted strings (#137)
1 parent 4198dc6 commit 6a6ddf8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct TypeMatcher {
215215
typeName = .swift("String")
216216
case .binary:
217217
typeName = .foundation("Data")
218-
case .date, .dateTime:
218+
case .dateTime:
219219
typeName = .foundation("Date")
220220
default:
221221
typeName = .swift("String")

Sources/swift-openapi-generator/Documentation.docc/Development/Converting-between-data-and-Swift-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Below is a list of the "dimensions" across which the helper methods differ:
5050
- **Swift type** represents the generated type in Swift that best represents the JSON schema defined in the OpenAPI document. For example, a `string` schema is generated as `Swift.String`, an `object` schema is generated as a Swift structure, and an `array` schema is generated as a `Swift.Array` generic over the element type. For the helper methods, it's important which protocol they conform to, as those are used for serialization. Values:
5151
- _string-convertible_ refers to types that conform to `LosslessStringConvertible`
5252
- _array of string-convertibles_ refers to an array of types that conform to `LosslessStringConvertible`
53-
- _date_ is represented by `Foundation.Date`
54-
- _array of dates_ refers to an array of `Foundation.Date`
53+
- _date-time_ is represented by `Foundation.Date`
54+
- _array of date-times_ refers to an array of `Foundation.Date`
5555
- _codable_ refers to types that conform to `Codable`
5656
- _data_ is represented by `Foundation.Data`
5757
- **Optional/required** represents whether the method works with optional values. Values:

Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_TypeMatcher.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class Test_TypeMatcher: Test_Core {
2626
(.string, "Swift.String"),
2727
(.string(.init(format: .byte), .init()), "Swift.String"),
2828
(.string(.init(format: .binary), .init()), "Foundation.Data"),
29-
(.string(.init(format: .date), .init()), "Foundation.Date"),
29+
(.string(.init(format: .date), .init()), "Swift.String"),
3030
(.string(.init(format: .dateTime), .init()), "Foundation.Date"),
3131

3232
(.integer, "Swift.Int"),

0 commit comments

Comments
 (0)