多态性与招摇工作不正常

问题描述 投票:3回答:1

我使用springfox版本2.9.2和招摇的注释1.5.x.该ApiModel注释支持这些要求作出多态性工作的鉴别,亚型和parent属性,但我没有看到产生,使多态性正确apidocs。

这是我的注释的代码。

@RestController
@RequestMapping("/api/vehicles")
public class VehicleController {
    private static final Logger LOGGER = LoggerFactory.getLogger(VehicleController.class);

    @PostMapping(consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    void post(@RequestBody Vehicle anyVehicle) {
        LOGGER.info("Vehicle : {}", anyVehicle);
    }
}

@ApiModel(discriminator = "type", subTypes = {Car.class, Bike.class})
public class Vehicle {
    String brand;
    String type;

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}


@ApiModel(parent = Vehicle.class)
public class Car extends Vehicle {
    int noOfDoors;
    boolean powerWindows;

    public int getNoOfDoors() {
        return noOfDoors;
    }

    public void setNoOfDoors(int noOfDoors) {
        this.noOfDoors = noOfDoors;
    }

    public boolean isPowerWindows() {
        return powerWindows;
    }

    public void setPowerWindows(boolean powerWindows) {
        this.powerWindows = powerWindows;
    }
}

@ApiModel(parent = Vehicle.class)
public class Bike extends Vehicle {
    boolean pillion;

    public boolean isPillion() {
        return pillion;
    }

    public void setPillion(boolean pillion) {
        this.pillion = pillion;
    }
}

当获得产生的文档是基本上示出了一个端点,其处理POST请求,并采取在车辆作为模型。

This is how the generated UI looks

就是我在这里做这样运作?有人能指出我的这个与SpringFox工作的例子,我可以看看?

swagger swagger-ui springfox
1个回答
1
投票

对于discriminator支持不扬鞭UI产品尚未推出。您可以按照这些问题的状态更新:

Discriminator does not switch schema subTypes not displayed in model

© www.soinside.com 2019 - 2024. All rights reserved.