Lilly Lilly - 1 year ago 287
Java Question

How to use ApiModelProperty in java using Swagger

I just want to make authorization required but I don't know exactly where to put:

@ApiModelProperty(value = "authorization", dataType = "java.lang.String", required = true) String authorization
in my method:

public Response getClienteFornitore(@HeaderParam("Authorization") String authorization, @HeaderParam("StaySignedIn") boolean staySignedIn, @PathParam("clienteFornitoreId") int clienteFornitoreId) {

....

}


I would really appreciate anyone who could help! Thank you!

dpr dpr
Answer Source

You can make authorization required by adding an @ApiParam annotation to the respective parameter in your method signature:

public Response getClienteFornitore(
    @ApiParam(value = "Authorization token", required = true) @HeaderParam("Authorization")  String authorization,
    @HeaderParam("StaySignedIn")  boolean staySignedIn, 
    @PathParam("clienteFornitoreId") int clienteFornitoreId) {
    ...
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download