Example 1 - Simple $xref example
This example shows how the yaml-combine plugin will import objects that are referenced using an $xref key, but will not import $ref keys.
$ref keys will be dereferenced via the existing swagger reference method.
Input
input.yaml
paths:
/thing:
get:
# acts like a $ref but in a place where $refs aren't allowed
$xref: 'paths.yaml#/paths/~1thing/get'
post:
$xref: 'paths-v2.yaml#/paths/~1thing/post'
paths.yaml
paths:
/thing:
get:
operationId: getThings
description: get all the things
parameters:
responses:
200:
schema:
type: object
title: getThingsOKResponse
properties:
status:
description: OK
type: string
thing:
type: array
items:
$ref: 'objects.yaml#/definitions/ThingObject'
paths-v2.yaml
paths:
/thing:
post:
operationId: addThing
description: |
Adds a new `Thing`.
* Things must be uniquely identifiable by `name`.
* The `id` of the thing must be empty; the newly created `id` will be returned in the response object.
parameters:
thing:
$ref: 'objects.yaml#/definitions/ThingObject'
responses:
200:
schema:
type: object
title: getThingsOKResponse
properties:
status:
description: OK
type: string
thing:
type: array
items:
$ref: 'objects.yaml#/definitions/ThingObject'
Output
---
paths:
/thing:
post:
operationId: addThing
description: |
Adds a new `Thing`.
* Things must be uniquely identifiable by `name`.
* The `id` of the thing must be empty; the newly created `id` will be returned in the response object.
responses:
200: null
schema:
type: object
title: getThingsOKResponse
properties:
thing:
type: array
items:
$ref: objects.yaml#/definitions/ThingObject
status:
type: string
description: OK
parameters:
thing:
$ref: objects.yaml#/definitions/ThingObject
get:
operationId: getThings
description: get all the things
responses:
200: null
schema:
type: object
title: getThingsOKResponse
properties:
thing:
type: array
items:
$ref: objects.yaml#/definitions/ThingObject
status:
type: string
description: OK
parameters: null