简体   繁体   中英

Exclude parameter from RequestBody - Swagger

I have two methods in one controller with the same obejct as arguments:

@PostMapping("/pg-import")
public String importProcessGroup(@RequestBody NiFiArguments niFiArguments) {
    log.info("Called method importFlow");

@PostMapping("/pg-change-version")
public String changeVersionProcessGroup(@RequestBody NiFiArguments niFiArguments) {
    log.info("Called method importFlow");

Pojo object:

@Data
public class NiFiArguments {

    private String bucketIdentifier;
    private String flowIdentifier;
    private String flowVersion;
    private String baseUrl;
    private String processGroupId;
}

I would like to exclude processGroupId attribute from importProcessGroup method. Is it possible?

One way to do that would be to Subclass NiFiArguments into a separate class.

@Data
public class NiFiArguments {

    private String bucketIdentifier;
    private String flowIdentifier;
    private String flowVersion;
    private String baseUrl;
}

@Data
public class NiFiArgumentsWithProcessGroup extends NiFiArguments {

    private String processGroupId;
}

Then use the different objects in your two methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM