简体   繁体   English

从 RequestBody 中排除参数 - Swagger

[英]Exclude parameter from RequestBody - Swagger

I have two methods in one controller with the same obejct as arguments:我在一个 controller 中有两种方法,其对象与 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:宝卓 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.我想从 importProcessGroup 方法中排除 processGroupId 属性。 Is it possible?可能吗?

One way to do that would be to Subclass NiFiArguments into a separate class.一种方法是将 NiFiArguments 子类化为单独的 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.然后在你的两种方法中使用不同的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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