Let's say I have some simple Order > OrderLines > Product Data Model in an OpenAPI document. The Components part would look like this:
components:
schemas:
Order:
required:
- orderId
properties:
orderId:
type: integer
orderlines:
type: array
items:
$ref: '#/components/schemas/OrderLine'
OrderLine:
required:
- orderLineId
- product
- price
properties:
orderLineId:
type: integer
product:
$ref: '#/components/schemas/Product'
price:
type: integer
Product:
required:
- productId
- name
x-keys:
- productId
properties:
productId:
type: integer
name:
type: string
When building a path to define an api to get a specific OrderLine on an Order, this would look like this:
paths:
/orders/{orderId}/orderlines/{orderLineId}:
get:
operationId: getOrderLine
parameters:
- in: path
name: orderId
schema:
type: integer
required: true
- in: path
name: orderLineId
schema:
type: integer
required: true
Now, the defined orderId parameters actually refers to the orderId property of the Order Component. And the same goes for parameter orderLineId which refers to the orderLineId property of Component OrderLine.
So is it possible to actually refer to these properties in the parameter definition instead of duplicating the type information of the properties?
I mean is it somehow possible to do something like this:
paths:
/orders/{orderId}/orderlines/{orderLineId}:
get:
operationId: getOrderLine
parameters:
- in: path
name: orderId
$ref: #components/schemas/Order/properties/orderId
required: true
- in: path
name: orderLineId
$ref: #components/schemas/OrderLine/properties/orderLineId
required: true