swagger4spring-web-0.3.2 (because production env uses Java 1.6)
Spring 4.0.2
My controllers get parsed correctly when simply using normal Spring annotations and swagger's @ApiOperation. However, I run into an issue when also using swagger's @Api annotation to add a description to my controller. The issue is that my required parameters in the controller aren't labeled as required anymore. I verify this by looking at the JSON that is produced in the resource list.
JSON snippet showing GET parameters for controller when using @Api as well as @ApiOperation:
@Controller
@RequestMapping(value = "/tag")
@Api(value="tag", description="Tag Controller")
public class TagController extends BasicController {
@Autowired
SubscriptionTagService subscriptionTagService;
@RequestMapping(method=RequestMethod.POST)
@ApiOperation(value = "Add a tag",
notes="Add a tag to a subscrition")
public void addTag(@ApiParam(value="Subscription Id") @RequestParam(value="id") String subscriptionId,
@ApiParam(value="Tag name") @RequestParam(value="tag") String tagName,
@ApiParam(value="Padding prefix for JSONP") @RequestParam(value="callback", required=false) String callback,
HttpServletRequest request) {
String username = getIdFromRequest(request);
subscriptionTagService.add(tagName, username, subscriptionId);
}
@RequestMapping(method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get subscription tags",
notes = "Gets the tags of a user's subscription",
response = Tag.class)
public @ResponseBody List getTags(@ApiParam(value="Subscription Id") @RequestParam(value="id") String subscriptionId,
@ApiParam(value="Padding prefix for JSONP") @RequestParam(value="callback", required=false) String callback,
HttpServletRequest request) {
String username = getIdFromRequest(request);
return subscriptionTagService.getSubscriptionTags(subscriptionId, username);
}
}
When I comment out @Api(value="tag", description="Tag Controller") the required parameters are correctly labeled.
Why would @Api be causing all parameters to have required = "false"? I have even tried to explicitly mark subscriptionId as required, but that doesn't have any effect.
I am using:
My controllers get parsed correctly when simply using normal Spring annotations and swagger's @ApiOperation. However, I run into an issue when also using swagger's @Api annotation to add a description to my controller. The issue is that my required parameters in the controller aren't labeled as required anymore. I verify this by looking at the JSON that is produced in the resource list.
JSON snippet showing GET parameters for controller when using @Api as well as @ApiOperation:
Here is the code for my controller:
When I comment out
@Api(value="tag", description="Tag Controller")
the required parameters are correctly labeled.Why would @Api be causing all parameters to have
required = "false"
? I have even tried to explicitly marksubscriptionId
as required, but that doesn't have any effect.