I'm using JSON Schema to document the response for a hotel availability search.
There are various prices and rates in the response. For example - to help the developer display the output, each hotel result provides the lowest total price for the dates requested, as well as the minimum daily rate.
The JSON response looks something like this
"property_name": "Winthrop Beach Inn And Suites Boston Logan",
"total_price": {
"amount": "129.00",
"currency": "USD"
},
"min_daily_rate": {
"amount": "115.00",
"currency": "USD"
},
"location": {
"latitude": 42.37655,
"longitude": -70.97375
},
Both of these elements are amount objects, and they are described by an amount schema, which reads like this
Amount:
required:
- currency
- amount
description: "A monetary amount with a price and a currency"
properties:
currency:
type: string
description: "ISO 4217 currency code applicable to this amount. For example: EUR."
amount:
type: string
description: "Total amount in the given currency, formatted appropriately. For example: 194.99"
You can see the
swagger specification here and a
sample response here for a more complete picture.
The amount object is quite self-explanatory, but each of these amounts have different meanings depending on their context which is not obvious. What's the difference between the total_price and the minimum_daily_rate, for example?
I'd like to be able to document this context for the user. Instinctively I wrote this:
total_price:
description: The lowest price of a stay, from the given check in date to the given check out date.
$ref: "#/definitions/Amount"
min_daily_rate:
description: The lowest price per day that the hotel offers between the given check-in and check-out dates. Extra taxes may apply to this rate.
$ref: "#/definitions/Amount"
... but, of course, this doesn't work, because the $ref changes the scope, so the description - and all other elements - are ignored. There doesn't seem to be a way to refer to the object and also describe the way in which it is used.
How can I document the context of each amount, without having to repeating all the other fields of the amount object?