Nested custom object having oneOf in swagger file result in empty model after code generation #4921
Labels
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
I am in the following situation:
I have a class in C# language defining primitive types + 1 custom type.
public class User {
public string firstName { get; set; }
public string lastName { get; set; }
public CustomCredentials customCredentials { get; set; }
}
public class CustomCredentials {
public string password { get; set; }
}
User class appears in my .NetCore controller in the endpoint where it is used, as part of
[SwaggerResponse(200. typeof(User))]
The corresponding part for CustomCredentials into swagger.json file is
"customCredentials": {
"nullable:" true,
"oneOf": [
"$ref": "#components/schemas/customCredentials"
]
}
During code generation a warning appears reporting The schema for that class with an undefined type and 'allOf/anyOf/oneOf is a bit ambiguous. As side effect the generated typescript class for customCredentials is empty, while the parent class is ok.
As workaround if I manually replace oneOf with allOf in swagger file before the library generation then the model is populated correctly.
Is there a right way to approach this problem?
Thanks
The text was updated successfully, but these errors were encountered: