MrNiamh
03/24/2025, 8:45 AMdata class FieldDTO(
val name: String,
val obj: ObjectField,
){
companion object {
val example = FieldDTO(
name = "Field",
obj = ObjectField.example
)
}
}
data class ObjectField(
val name: String,
val field: FieldDTO? = null,
){
companion object {
val example = ObjectField("obj", field = FieldDTO.example)
}
}
The compiler obviously throws an error on the ObjectField
example, but if I set the example to be ObjectField("obj", field = null)
then I get an issue with NoFieldFound
on generating the openapi as it doesn't like having nulls.
Tried to have a search but couldn't find much on what the best approach here is!Andrew O'Hara
03/24/2025, 10:17 PMrenderer
in the contract builder?MrNiamh
03/25/2025, 8:21 AMrenderer = OpenApi3(ApiInfo("Backend", "v1.0", "API"), CustomJackson())
However I was having a play around with passing in a new renderer but wasn't quite playing nicely. If you had any good examples that'd be greatAndrew O'Hara
03/25/2025, 12:55 PMCustomJackson
might be the issue. The default is OpenApiJackson
which addresses the null serialization issue. You specifically need to add this to your custom jackson.
.setSerializationInclusion(NON_NULL)
MrNiamh
03/25/2025, 5:46 PM