electrode-native
electrode-native copied to clipboard
`ern regen-api` generates incorrect Swift code for `enum` fields
in schema.json
offerType
is defined as enum
"definitions": {
"Offer": {
"type": "object",
"required": [
"id",
"sellerName",
"sellerId",
"offerType",
"currentPrice"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"sellerName": {
"type": "string"
},
"sellerId": {
"type": "integer",
"format": "int64"
},
"offerType": {
"type": "string",
"enum": ["1P", "3P"]
},
"currentPrice": {
"type": "number",
"format": "float"
}
}
},
Running ern regen-api
creates Offer.swift
with code
@objcMembers public class Offer: ElectrodeObject, Bridgeable {
private static let tag = String(describing: type(of: self))
public let id: Int64
public let sellerName: String
public let sellerId: Int64
public let currentPrice: Float
public init(id: Int64, sellerName: String, sellerId: Int64, offerType: OfferType, currentPrice: Float) {
self.id = id
self.sellerName = sellerName
self.sellerId = sellerId
self.offerType = offerType
self.currentPrice = currentPrice
super.init()
}
....
Notice that offerType
is missing in class fields definitions and OfferType
is not defined anywhere
attempting to compile this code produces
Showing All Messages
/ElectrodeContainer/APIs/Offer.swift:11:76: Use of undeclared type 'OfferType'
/ElectrodeContainer/APIs/Offer.swift:25:9: Value of type 'Offer' has no member 'offerType'
Android Java class definitions seem to be valid, but enum
is not created, and it's simply String
field that can accept any value
@romanlv We currently do not support enums. Will add this as a future enhancement.