I'm using swagger to generate interfaces and models for my endpoints in kura, however the generated "@JsonProperty("fieldName")" annotation (from "com.fasterxml.jackson.annotation") in the model class does not seem to work.
My generated endpoint interface:
@Path("/contact")
@Api(description = "the contact API")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2019-08-28T13:04:01.544+03:00")
public interface ContactApi {
@POST
@Produces({ "application/json" })
@ApiOperation(value = "Add new contact", notes = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "succsseful operation", response = Void.class) })
void contactPost(@Valid Contact contact);
}
My generated model:
public class Contact implements Serializable {
private @Valid String [b]contactId[/b] = null;
....
@ApiModelProperty(value = "")
@JsonProperty("[b]contact_id[/b]")
public String getContactId() {
return [b]contactId[/b];
}
public void setContactId(String contactId) {
this.contactId = contactId;
}
...
}
When someone calls this endpoint with json that has "contact_id" field, it should be mapped to "contactId", but this does not work, so whichever service is doing the mapping does not seem to read the "@JsonProperty" annotation.
Has anyone tried to use the "@JsonProperty" annotation and had it working? Is it possible that "com.eclipsesource.jaxrs.jersey-min_2.22.2" might not support jackson annotations?
[Updated on: Thu, 29 August 2019 04:45]
Report message to a moderator