Description
"Person": {
"type": "object",
"properties": {
"Id": {
"type": "string",
"format": "uuid"
},
"type": {
"title": "Discriminator Type",
"type": "string"
}
},
"additionalProperties": false,
"discriminator": {
"propertyName": "type",
"mapping": {
//Self reference
"person": "#/components/schemas/Person",
"author": "#/components/schemas/Author"
}
}
},
leads to this code:
@override
Object serialize(
Serializers serializers,
Person object, {
FullType specifiedType = FullType.unspecified,
}) {
if (object is Author) {
return serializers.serialize(object,
specifiedType: FullType(Author))!;
}
// this block should be removed entirely, leads to recursion
if (object is Person) {
return serializers.serialize(object,
specifiedType: FullType(Person))!;
}
//====================================
return _serializeProperties(serializers, object,
specifiedType: specifiedType)
.toList();
}
and
switch (discValue) {
case r'author':
return serializers.deserialize(serialized,
specifiedType: FullType(Author))
as Author;
// this block should be removed entirely, leads to recursion
case r'person':
return serializers.deserialize(serialized,
specifiedType: FullType(Person))
as Person;
//====================================
default:
return serializers.deserialize(serialized,
specifiedType: FullType($Person))
as $Person;
}
and
extension PersonDiscriminatorExt
on Person {
String? get discriminatorValue {
if (this is Author) {
return r'author';
}
/// This check should be removed, and instead of returning null at the end, should return r'person'
if (this is Person) {
return r'person';
}
return null;
}
}
extension PersonBuilderDiscriminatorExt
on PersonBuilder {
String? get discriminatorValue {
if (this is AuthorBuilder) {
return r'author';
}
/// This check should be removed, and instead of returning null at the end, should return r'person'
if (this is PersonBuilder) {
return r'person';
}
return null;
}
}
openapi-generator version
6.6.0
I plan on fixing this in an upcoming PR, will introduce a new vendor extension called fallback case, which will be the concrete class in this case ($Person) and remove self references from mappings in java
@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)
Description
leads to this code:
and
and
openapi-generator version
6.6.0
I plan on fixing this in an upcoming PR, will introduce a new vendor extension called fallback case, which will be the concrete class in this case (
$Person) and remove self references from mappings in java@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)