Skip to content

Commit 20df8ec

Browse files
Anthony TODISCOAnthony TODISCO
authored andcommitted
Merge branch 'fix/protobuf-discriminator-issues' of https://github.com/Ocsidot/openapi-generator into fix/protobuf-discriminator-issues
2 parents a8b6f0d + c7cb481 commit 20df8ec

1,257 files changed

Lines changed: 15350 additions & 7483 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Mill plugin tests
2+
3+
on:
4+
push:
5+
paths:
6+
- modules/openapi-generator-mill-plugin/**
7+
pull_request:
8+
paths:
9+
- modules/openapi-generator-mill-plugin/**
10+
11+
jobs:
12+
test:
13+
name: Mill plugin tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- name: Set up JDK 11
18+
uses: actions/setup-java@v5
19+
with:
20+
java-version: 11
21+
distribution: 'temurin'
22+
- name: Restore cache (read-only)
23+
# only use restore keys, no save key because we need to clear the cache before running the examples
24+
uses: actions/cache/restore@v5
25+
with:
26+
path: |
27+
~/.m2/repository
28+
~/.gradle
29+
~/.cache/coursier
30+
!~/.gradle/caches/*/plugin-resolution/
31+
!~/.m2/repository/org/openapitools/
32+
!~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/openapitools/
33+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
34+
35+
- name: Maven Clean Install
36+
env:
37+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
38+
run: |
39+
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
40+
41+
# This is needed because of differences in how Maven and Coursier download artifacts
42+
# Maven will only download the pom when the transitive dependency is not needed in the current projects compile classpath
43+
# whereas Coursier expects the artifact (jar) to be present in a Maven repository. When Coursier encounters a
44+
# artifact folder with a pom it considers the artifact to be available and will then crash when the jar is missing.
45+
- name: Clear m2 cache except openapitools (because otherwise coursier will fail to resolve artifacts where only poms are downloaded)
46+
run: |
47+
mv ~/.m2/repository/org/openapitools /tmp/openapitools-backup || true
48+
rm -rf ~/.m2/repository/*
49+
mkdir -p ~/.m2/repository/org
50+
mv /tmp/openapitools-backup ~/.m2/repository/org/openapitools || true
51+
52+
- name: Mill Example - Test Validation Command
53+
env:
54+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
55+
run: |
56+
(cd modules/openapi-generator-mill-plugin/example/ && ./mill validateOpenapiSpec $(pwd)/api/petstore-invalid.yaml)
57+
58+
- name: Mill Example - Test Validation Task
59+
env:
60+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
61+
run: |
62+
(cd modules/openapi-generator-mill-plugin/example/ && ./mill openapi.validate)
63+
64+
- name: Mill Example - Test Compile Task
65+
env:
66+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
67+
run: |
68+
(cd modules/openapi-generator-mill-plugin/example/ && ./mill __.compile)
69+

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPY ./google_checkstyle.xml ${GEN_DIR}
1313
# All poms are copied, then we go offline, to allow for better caching of code changes without fetching all dependencies each time
1414
COPY ./modules/openapi-generator-gradle-plugin/pom.xml ${GEN_DIR}/modules/openapi-generator-gradle-plugin/
1515
COPY ./modules/openapi-generator-maven-plugin/pom.xml ${GEN_DIR}/modules/openapi-generator-maven-plugin/
16+
COPY ./modules/openapi-generator-mill-plugin/pom.xml ${GEN_DIR}/modules/openapi-generator-mill-plugin/
1617
COPY ./modules/openapi-generator-online/pom.xml ${GEN_DIR}/modules/openapi-generator-online/
1718
COPY ./modules/openapi-generator-cli/pom.xml ${GEN_DIR}/modules/openapi-generator-cli/
1819
COPY ./modules/openapi-generator-core/pom.xml ${GEN_DIR}/modules/openapi-generator-core/
@@ -23,6 +24,7 @@ RUN mvn dependency:go-offline
2324
# Modules are copied individually here to allow for caching of docker layers between major.minor versions
2425
COPY ./modules/openapi-generator-gradle-plugin ${GEN_DIR}/modules/openapi-generator-gradle-plugin
2526
COPY ./modules/openapi-generator-maven-plugin ${GEN_DIR}/modules/openapi-generator-maven-plugin
27+
COPY ./modules/openapi-generator-mill-plugin ${GEN_DIR}/modules/openapi-generator-mill-plugin
2628
COPY ./modules/openapi-generator-online ${GEN_DIR}/modules/openapi-generator-online
2729
COPY ./modules/openapi-generator-cli ${GEN_DIR}/modules/openapi-generator-cli
2830
COPY ./modules/openapi-generator-core ${GEN_DIR}/modules/openapi-generator-core

bin/configs/html.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: html
2+
outputDir: samples/documentation/html
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/htmlDocs
5+
additionalProperties:
6+
hideGenerationTimestamp: "true"

bin/configs/swift6-vapor.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ generateAliasAsModel: true
77
additionalProperties:
88
projectName: PetstoreClient
99
useSPMFileStructure: true
10-
useClasses: true
10+
useClasses: false
1111
useBacktickEscapes: true
1212
mapFileBinaryToData: true

bin/generate-samples.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ For example:
4747

4848
echo "$header"
4949

50+
tmpfile=$(mktemp)
51+
trap "rm -f $tmpfile" EXIT
52+
5053
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
51-
# shellcheck disable=SC2086
52-
# shellcheck disable=SC2068
53-
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
54+
# shellcheck disable=SC2086
55+
# shellcheck disable=SC2068
56+
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile"
57+
retcode=${PIPESTATUS[0]}
5458
else
55-
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
56-
#sleep 5
57-
if [ ${#files[@]} -eq 0 ]; then
58-
files=("${root}"/bin/configs/*.yaml)
59-
fi
59+
if [ ${#files[@]} -eq 0 ]; then
60+
files=("${root}"/bin/configs/*.yaml)
61+
fi
6062

61-
# shellcheck disable=SC2086
62-
# shellcheck disable=SC2068
63-
if java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee /dev/pts/0 | grep -q -i "exception"; then
64-
echo "Found exception(s) when running the generator(s) to update the samples."
65-
export GENERATE_ERROR=1
66-
fi
63+
# shellcheck disable=SC2086
64+
# shellcheck disable=SC2068
65+
java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile"
66+
retcode=${PIPESTATUS[0]}
6767
fi
6868

69-
if [[ -n "$GENERATE_ERROR" ]]; then
69+
if [[ $retcode -ne 0 ]] || grep -q -i "at org.openapitools" "$tmpfile"; then
7070
echo "Found exception(s) when running the generator(s) to update the samples."
7171
exit 1
7272
fi

bin/utils/release/release_version_update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ declare -a xml_files=(
9393
declare -a properties_files=(
9494
"${root}/modules/openapi-generator-gradle-plugin/gradle.properties"
9595
"${root}/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
96+
"${root}/modules/openapi-generator-mill-plugin/example/mill-build/version.properties"
9697
)
9798

9899
${cwd}/bump.sh -f ${version} -i ${inc} ${xml_files[@]}

bitrise.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ workflows:
2727
set -e
2828
2929
./samples/client/petstore/swift6/swift6_test_all.sh
30-
- script@1.2.0:
31-
title: Run Swift5 tests
32-
inputs:
33-
- content: |
34-
#!/usr/bin/env bash
35-
36-
set -e
37-
38-
./samples/client/petstore/swift5/swift5_test_all.sh
3930
- script@1.2.0:
4031
title: Run swift-combine tests
4132
inputs:

docs/generators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The following generators are available:
6868
* [scala-sttp4-jsoniter (beta)](generators/scala-sttp4-jsoniter.md)
6969
* [scalaz](generators/scalaz.md)
7070
* [swift-combine](generators/swift-combine.md)
71-
* [swift5](generators/swift5.md)
71+
* [swift5 (deprecated)](generators/swift5.md)
7272
* [swift6](generators/swift6.md)
7373
* [typescript (experimental)](generators/typescript.md)
7474
* [typescript-angular](generators/typescript-angular.md)

docs/generators/swift5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Documentation for the swift5 Generator
77
| Property | Value | Notes |
88
| -------- | ----- | ----- |
99
| generator name | swift5 | pass this to the generate command after -g |
10-
| generator stability | STABLE | |
10+
| generator stability | DEPRECATED | |
1111
| generator type | CLIENT | |
1212
| generator language | Swift | |
1313
| generator default templating engine | mustache | |

docs/plugins.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,56 @@ openApiGenerate {
120120
```
121121
122122
*If you want to create separate tasks (for example when you have more than one api spec and require different parameters for each), this is how to do so in Gradle 7+: `tasks.register('taskName', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { ... }`.*
123+
124+
## Mill
125+
126+
This Mill library provides a Mill module that can be used to generate code from OpenAPI specifications.
127+
128+
### Example
129+
130+
```scala
131+
//| mill-version: 1.0.6
132+
//| mvnDeps:
133+
//| - org.openapitools:openapi-generator-mill-plugin:7.20.0 # 1.
134+
135+
import mill.*
136+
137+
import org.openapitools.generator.mill.OpenApiModule // 2.
138+
139+
object `package` extends JavaModule with MavenModule with OpenApiModule { // 3.
140+
141+
// other Mill config...
142+
143+
object openapi extends OpenApiConfig { // 4.
144+
def inputSpec: T[PathRef] = Task.Source(BuildCtx.workspaceRoot / "api" / "petstore.yaml")
145+
// other config options...
146+
}
147+
148+
override def generatedSources: T[Seq[PathRef]] = Seq(
149+
PathRef(Task.dest),
150+
openapi.generate(), // 5.
151+
)
152+
}
153+
```
154+
155+
1. Add the plugin to your `build.mill` as `mvnDeps` in the header section
156+
2. import `org.openapitools.generator.mill.OpenApiModule`
157+
3. add `OpenApiModule` to the module definition
158+
4. configure 1-n `OpenApiConfig` as sub-modules
159+
5. run the generation as part of the `compile` task
160+
161+
This gives access to the following tasks:
162+
163+
| Task | Description |
164+
|---------------------------|---------------------------------------------------------------------------------------------|
165+
| <configName>.generate | Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents. |
166+
| <configName>.validateSpec | Validates the configured spec |
167+
168+
and a command
169+
170+
| Command | Description |
171+
|---------------------|------------------------------------------------|
172+
| validateOpenapiSpec | Takes the path to a spec file and validates it |
173+
174+
175+
For full details of all options, see the [plugin README](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-mill-plugin).

0 commit comments

Comments
 (0)