У меня есть следующая конечная точка определения API:
paths:
/pricing/reservation:
get:
tags:
- Pricing
summary: Get a reservation base price
description: Returns the pricing for a reservation
operationId: getReservationPricing
produces:
- application/json
parameters:
- name: beginDate
in: query
description: reservation begin date
required: true
type: integer
format: int64
- name: endDate
in: query
description: reservation end date
required: true
type: integer
format: int64
- in: body
name: vehicle
description: Vehicle objec
required: true
schema:
$ref: '#/definitions/Vehicle'
responses:
200:
description: successful operation
schema:
type: number
format: float
404:
description: Vehicle not found
Я хочу запросить объект Vehicle
по параметру, а затем, с интеграцией Bitbucket, сгенерировать интерфейс API в Java. Таким образом, я могу переопределить контроллер API и определить логику конечной точки.
У меня вопрос: есть ли способ определить универсальный объект из определения Swagger, или у меня есть (как я делал в приведенном выше коде) определение моего объекта Swagger и затем отобразить его в Java?
API сгенерированный интерфейс со схемой Swagger:
@ApiOperation(value = "Get a reservation base price", nickname = "getReservationPricing", notes = "Returns the pricing for a reservation", response = Float.class, authorizations = {
@Authorization(value = "api_key")
}, tags={ "Pricing", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Float.class),
@ApiResponse(code = 404, message = "Vehicle not found") })
@RequestMapping(value = "/pricing/reservation",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<Float> getReservationPricing(@NotNull @ApiParam(value = "reservation begin date", required = true) @Valid @RequestParam(value = "beginDate", required = true) Long beginDate,@NotNull @ApiParam(value = "reservation end date", required = true) @Valid @RequestParam(value = "endDate", required = true) Long endDate,@ApiParam(value = "Vehicle object that needs to be added to the fleet" ,required=true ) @Valid @RequestBody Vehicle vechicle);
Спасибо за вашу помощь!