Generate merge spec#14387
Conversation
|
@wing328 (2015/07) ❤️ |
18eb87e to
e40ae08
Compare
2a10be3 to
df0d106
Compare
|
@wing328 could you please review once you have a time? |
|
@borsch thanks for the PR as always. do we need to update openapi-generator-cli module to support the new option as well? currently, the users need to use a script or something to loop through all the spec in a folder in order to achieve the same ,right? |
Thanks. Sure, will add CLI support. #!/bin/bash
API_HEADER="openapi: '3.0.0'
info:
description: Merge description
version: '1.0'
title: Merge title
servers:
- url: https://localhst:8079
paths:\n"
printf "%s${API_HEADER}" >> "src/main/resources/contract/_index_auto.yaml"
grep --exclude='*index*' -E '^ */' "src/main/resources/contract"/* | sort | while read -r line; do
path=$(echo "$line" | awk '{print $2}')
fileName=$(echo "$line" | awk '{print $1}' | awk -F "/" '{print $NF}' | sed 's/:*$//g')
# shellcheck disable=SC2001
ref=$(echo "${path//\//~1}" | sed 's/:*$//g')
printf "
%s$path
\$ref: './%s$fileName#/paths/%s$ref'\n" >> "src/main/resources/contract/_index_auto.yaml"
done
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-openapi-common-file</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>bash</executable>
<arguments>
<argument>generate_open_api.sh</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin> |
b6cdf1b to
3fadbbb
Compare
|
@wing328 I've applied change to CLI module |
3fadbbb to
743172e
Compare
|
i just merged a PR with updated samples. can you merge the latest master into your branch? |
|
Did some tests and the result is good 👍 I will merge when all CI tests pass. Thanks again for the PR. |
743172e to
6dd606d
Compare
|
Hello, I encountered several problems when using
but i got
|
| "version", "1.0.0" | ||
| )); | ||
| map.put("servers", Collections.singleton( | ||
| ImmutableMap.of("url", "http://localhost:8080") |
There was a problem hiding this comment.
Hi, why not include the servers array from one or more of the input files?
There was a problem hiding this comment.
I have abandoned this plugin and use redocly
tasks.register<Exec>("mergeOpenApiSpecs") {
val specs = projectDir.resolve("src/main/resources/openapi").listFiles()!!.filter { it.name != "merged.yml" }
.map { it.name }.toTypedArray()
commandLine(
"docker",
"run",
"--rm",
"-v",
"${projectDir.resolve("src/main/resources/openapi").absolutePath}:/spec",
"redocly/cli:1.12.2",
"join",
"--without-x-tag-groups",
*specs,
"-o",
"merged.yml"
)
}
There was a problem hiding this comment.
Doing the merge explicitly is not that hard and offers more flexibility, but I guess it's useful to have a built-in one that does the job for many use cases. @borsch

Implementation for #3981
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(6.3.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks)