Is it intend to generate schemas from optionals li...
# ktor
f
Is it intend to generate schemas from optionals like this?
Copy code
"DeviceNotificationTokens?": {
    "type": [
        "object",
        "null"
    ],
    "title": "DeviceNotificationTokens?",
    "oneOf": [
        {
            "$ref": "#/components/schemas/AndroidDeviceNotificationTokens"
        },
        {
            "$ref": "#/components/schemas/AppleDeviceNotificationTokens"
        }
    ],
    "discriminator": {
        "propertyName": "type",
        "mapping": {
            "AndroidDeviceNotificationTokens": "#/components/schemas/AndroidDeviceNotificationTokens",
            "AppleDeviceNotificationTokens": "#/components/schemas/AppleDeviceNotificationTokens"
        }
    }
},
at least the swift-open-api generator fails for ? in schema names
h
Yeah, you should not have an ? inside the name.
Is it a top level object or an inlined one? Because using null inside an top level object is strange too.
f
Yeah top-level
#/components/schemas/
Yeah, you should have an ? inside the name.
Really? I also have an example where it generated
MyClass?
and
MyClass
because in one place the property is optional and in the other it is not.
h
Okay, after the spec again, nullable references as know in OOP are hard to model as a constraint system. You could either always use type: object, "null" and restrict the non null type for a member or use top level objects without null and use anyOf with type "null": https://github.com/OAI/OpenAPI-Specification/issues/1368#issuecomment-2348536722