Overview
yaml-combine-maven-plugin is a maven plugin which provides a pre-processor for combining YAML source files, before those files are then used to generate even more code using the swagger toolchain.
This plugin exists mainly because $ref references are only allowed in one or two places in the swagger spec, and you may want to import objects in other locations.
Goals
- yaml-combine:yaml-combine combines a bunch of yaml files into a big yaml file
Syntax
yaml-combine extends the swagger interface definition language with a new $xref referencing method, but it is not limitted to just processing swagger files.
Details on using $xrefs can be found on the github README.
Some more specific use cases are described in the examples below.
Examples
- Simple $xref example - resolves $xrefs, but not $refs
- Escaping paths example - same as above, but shows how '#' can toggle JSON-Pointer escaping rules
- Override keys example - overriding keys in the imported object
- Multiple inputs example - combining multiple input files
- Simple $xref example with filtering - maven ${} substitution during processing
Usage
To use this plugin, include it in your project model
<project> <build> <plugins> <plugin> <groupId>com.randomnoun.maven.plugins</groupId> <artifactId>yaml-combine-maven-plugin</artifactId> <version>2.0.8</version> <executions> <execution> <id>yaml-combine</id> <phase>generate-sources</phase> <goals> <goal>yaml-combine</goal> </goals> <configuration> <fileset> <includes> <!-- can supply multiple files here or filespecs; e.g. *.yaml --> <include>my-yaml-file-with-xrefs-in-it.yaml</include> </includes> <directory>${project.basedir}/src/main/yaml</directory> </fileset> <outputDirectory>${project.basedir}/target/yaml-combine</outputDirectory> <!-- use this file as the input to the codegen goal --> <finalName>my-yaml-file-with-resolved-xrefs.yaml</finalName> </configuration> </execution> </executions> </plugin> <plugins> <build> <project>