-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Origin: https://stackoverflow.com/q/50163882/131929
The Swagger Java codegen produces a class like this:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "errorType", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = SpecificError.class, name = "SpecificError"),
})
public class GeneralError {
@JsonProperty("errorType")
private String errorType = null;
// accessors, even for errorType!, follow here
The Jackson serializer, version 2.9.4, produces JSON that includes the errorType
property twice:
{"errorType":"SpecificError","message":"message","errorType":null}
My test bed is as follows:
SpecificError specificError = (SpecificError) new SpecificError().message("message")
ObjectMapper objectMapper = new ObjectMapper();
ObjectWriter writer = objectMapper.writer();
System.out.println(writer.writeValueAsString(clientError));
I'm not 100% sure if Jackson is supposed to behave like that given the annotations you see above. Based on what I read in the JsonTypeInfo
Javadoc it seems incorrect. However, I also raised this as swagger-api/swagger-codegen#8137.
vojtechhabarta, Duncol, VadimKirilchuk, lolo101 and qeesung
Metadata
Metadata
Assignees
Labels
No labels