I have the following API definition endpoint:
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
I want to request a Vehicle
object by parameter and then, with the Bitbucket integration, generate the API interface in Java. That way I can override the API controller and define the endpoint logic.
My question is, is there a way to define a generic object from Swagger definition, or do I have (as I did in above code) to define my Swagger object definition and then map it in Java?
The API generated inteface with Swagger schema:
@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);
Thanks for your help!