Example 5 - Simple $xref example with filtering
This example shows how enabling the filtering configuration option causes maven to substitute properties into the generated YAML file
(This example is identical to Example 1 but has an additional '${pom.version}' value in the info block.
For filtering to be enabled, include
<filtering>true</filtering>
in the configuration block of the plugin.
Input
input.yaml
info: # the API version in the generated swagger spec will match # the version number in your pom.xml file version: "${pom.version}" title: Thing API paths: /thing: get: $xref: 'paths.yaml#/paths/#/thing#/get' post: $xref: 'paths-v2.yaml#/paths/#/thing#/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
--- info: version: "1.0.0-SNAPSHOT" title: Thing API 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