Search code examples
javaswagger

Swagger, tag based conditional description for the api


I am relatively new to swagger. I have a case where I have an api with 2 tags as mentioned below.

    @ApiOperation(value = "readplans", nickname="readplans",notes = "readplansfortag1, readplansfortag2", tags = {"tag1","tag2"})
    @RequestMapping(value = "/readplans", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String[]> readplans() {
        log.info("readAddonPlansByBasePlan() - start");
        String a ={"plana","planb","planc"};
        log.info("readAddonPlansByBasePlan()  -end");
        return new ResponseEntity<>(a, "OK");

    }

Now, I want to give different descriptions like readplansfortag1 when it is shown under tag1 and readplansfortag2 when it is shown under tag2.

Any help would be appreciated!!


Solution

  • It's not possible.

    The only workaround is to have two different paths, for example, /readplans1 under tag1 and /readplans2 under tag2. In this case you can have a unique description for each path.