-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
For readability purposes, I redefined UUID in my OpenAPI 3 schemas.
components:
schemas:
UUID:
description: A `UUID` (or `GUID`).
type: string
format: uuid
example: ad959e79-55c3-4445-8c51-a74b6d52691aThis generates:
//
// UUID.swift
//
// Generated by bow-openapi
// Copyright © 2021 Bow Authors. All rights reserved.
//
import Foundation
/// A `UUID` (or `GUID`).
public struct UUID: Codable {
}(Note the '`' character not escaped by swagger-codegen by the way)
The problem is that you add an extension to Foundation's UUID in Extensions.swift:
extension UUID: JSONEncodable {
func encodeToJSON() -> Any {
return self.uuidString
}
}But due to the local redeclaration of UUID, this extension points to our public struct UUID: Codable. Therefore it generates a compilation error: Value of type 'UUID' has no member 'uuidString'.
Proposed solution
Do not redefine a type: string with format: uuid, and use Foundation's UUID instead.
Additional remarks
- There may be a problem with
Date, which usesDateFormatter'sfunc string(from date: Date) -> String. I definedDateTime, so I don't have the problem. - There could be problems with other Foundation types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels