Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add oneOf handling for kotlinx.serialization #1

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
324 changes: 179 additions & 145 deletions .github/workflows/openapi-generator.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: OpenAPI Generator

permissions:
contents: write

on:
push:
branches:
- master
- '[5-9]+.[0-9]+.x'
# branches:
# - master
# - '[5-9]+.[0-9]+.x'
pull_request:
branches:
- master
Expand Down Expand Up @@ -36,158 +39,189 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run maven
run: ./mvnw clean --no-snapshot-updates --batch-mode --quiet install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=error
run: ./mvnw clean package -DskipTests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- run: ls -la modules/openapi-generator-cli/target
- name: Upload openapi-generator-cli.jar artifact
uses: actions/upload-artifact@v4
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target/openapi-generator-cli.jar
retention-days: 1

test:
name: Unit tests
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Cache maven dependencies
uses: actions/cache@v4
env:
cache-name: cache-maven-repository
with:
path: |
~/.m2/repository
~/.gradle
!~/.gradle/caches/*/plugin-resolution/
!~/.m2/repository/org/openapitools/
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Run unit tests
run: ./mvnw clean --no-snapshot-updates --batch-mode --quiet --fail-at-end test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Publish unit test reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'

documentation:
name: Docs up-to-date
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v4
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
- name: Generate docs
- name: Extract current branch name
id: branch-name
run: |
bash bin/meta-codegen.sh
bash bin/utils/export_docs_generators.sh
bash bin/utils/copy-to-website.sh
bash bin/utils/export_generators_readme.sh
- name: Verify git status
BRANCH_NAME=${{ github.ref }}
echo "Full ref: $BRANCH_NAME"
# Strip the refs/heads/ part to get the branch name
BRANCH_NAME=${BRANCH_NAME#refs/heads/}
echo "::set-output name=branch_name::$BRANCH_NAME"

- name: Generate tag string
id: generate_snapshot_string
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo "UNCOMMITTED CHANGES ERROR"
echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
echo "Perform git diff"
git --no-pager diff
echo "Perform git status"
git status
echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
echo -e "rebase or merge into your branch.\n"
echo "Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi
SNAPSHOT_STRING="tidal-SNAPSHOT-$(date +%Y-%m-%d)"
echo "Generated string: $SNAPSHOT_STRING"

samples:
name: Samples up-to-date
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
# Set the output for this step
echo "::set-output name=snapshot_string::$SNAPSHOT_STRING"

- name: Generate Release Draft
id: generate-release
uses: ncipollo/release-action@v1
with:
java-version: 11
distribution: 'temurin'
- name: Download openapi-generator-cli.jar artifact
uses: actions/download-artifact@v4
tag: ${{ steps.generate_snapshot_string.outputs.snapshot_string }}
allowUpdates: true
draft: true
body: "This is a release draft for ${{ github.ref }}"

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
name: openapi-generator-cli.jar
path: modules/openapi-generator-cli/target
- name: Delete samples that are entirely generated
run: |
rm -rf samples/client/petstore/csharp/generichost/latest/Tags
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: modules/openapi-generator-cli/target/openapi-generator-cli.jar
asset_name: openapi-generator-cli.jar
tag: ${{ steps.generate_snapshot_string.outputs.snapshot_string }}
overwrite: true
target_commit: ${{ steps.branch-name.outputs.branch_name }}
body: "This is the latest snapshot release of our openapi-generator fork"
# test:
# name: Unit tests
# runs-on: ubuntu-latest
# needs:
# - build
# steps:
# - uses: actions/checkout@v4
# - name: Set up JDK 11
# uses: actions/setup-java@v4
# with:
# java-version: 11
# distribution: 'temurin'
# - name: Cache maven dependencies
# uses: actions/cache@v4
# env:
# cache-name: cache-maven-repository
# with:
# path: |
# ~/.m2/repository
# ~/.gradle
# !~/.gradle/caches/*/plugin-resolution/
# !~/.m2/repository/org/openapitools/
# key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# - name: Run unit tests
# run: ./mvnw clean --no-snapshot-updates --batch-mode --quiet --fail-at-end test -Dorg.slf4j.simpleLogger.defaultLogLevel=error
# env:
# GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# - name: Publish unit test reports
# if: ${{ always() }}
# uses: actions/upload-artifact@v4
# with:
# name: surefire-test-results
# path: '**/surefire-reports/TEST-*.xml'

rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
# documentation:
# name: Docs up-to-date
# runs-on: ubuntu-latest
# needs:
# - build
# steps:
# - uses: actions/checkout@v4
# - name: Set up JDK 11
# uses: actions/setup-java@v4
# with:
# java-version: 11
# distribution: 'temurin'
# - name: Download openapi-generator-cli.jar artifact
# uses: actions/download-artifact@v4
# with:
# name: openapi-generator-cli.jar
# path: modules/openapi-generator-cli/target
# - name: Generate docs
# run: |
# bash bin/meta-codegen.sh
# bash bin/utils/export_docs_generators.sh
# bash bin/utils/copy-to-website.sh
# bash bin/utils/export_generators_readme.sh
# - name: Verify git status
# run: |
# if [[ "$(git status --porcelain)" != "" ]]; then
# echo "UNCOMMITTED CHANGES ERROR"
# echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
# echo "Perform git diff"
# git --no-pager diff
# echo "Perform git status"
# git status
# echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
# echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
# echo -e "rebase or merge into your branch.\n"
# echo "Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
# exit 1
# fi

rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore
# samples:
# name: Samples up-to-date
# needs:
# - build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up JDK 11
# uses: actions/setup-java@v4
# with:
# java-version: 11
# distribution: 'temurin'
# - name: Download openapi-generator-cli.jar artifact
# uses: actions/download-artifact@v4
# with:
# name: openapi-generator-cli.jar
# path: modules/openapi-generator-cli/target
# - name: Delete samples that are entirely generated
# run: |
# rm -rf samples/client/petstore/csharp/generichost/latest/Tags

rm -rf samples/client/petstore/csharp/generichost/net4.8/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.8/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.8/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.8/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate
# rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
# rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
# rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
# rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
# rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
# rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
# rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
# rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
# rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate

rm -rf samples/client/petstore/csharp/generichost/net4.7/AllOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare
rm -rf samples/client/petstore/csharp/generichost/net4.7/FormModels
rm -rf samples/client/petstore/csharp/generichost/net4.7/OneOf
rm -rf samples/client/petstore/csharp/generichost/net4.7/Petstore
rm -rf samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate
- name: Generate samples
run: |
bash bin/generate-samples.sh
# when a sample is deleted, you have to generate it twice for all files to get created
bash bin/generate-samples.sh
- name: Verify git status
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo "UNCOMMITTED CHANGES ERROR"
echo "There are uncommitted changes in working tree after execution of 'bin/generate-samples.sh'"
echo "Perform git diff"
git --no-pager diff
echo "Perform git status"
git status
echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
echo -e "rebase or merge into your branch.\n"
echo "Please run 'bin/generate-samples.sh' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
fi
# rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore

# rm -rf samples/client/petstore/csharp/generichost/net4.8/AllOf
# rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOf
# rm -rf samples/client/petstore/csharp/generichost/net4.8/AnyOfNoCompare
# rm -rf samples/client/petstore/csharp/generichost/net4.8/FormModels
# rm -rf samples/client/petstore/csharp/generichost/net4.8/OneOf
# rm -rf samples/client/petstore/csharp/generichost/net4.8/Petstore
# rm -rf samples/client/petstore/csharp/generichost/net4.8/UseDateTimeForDate

# rm -rf samples/client/petstore/csharp/generichost/net4.7/AllOf
# rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOf
# rm -rf samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare
# rm -rf samples/client/petstore/csharp/generichost/net4.7/FormModels
# rm -rf samples/client/petstore/csharp/generichost/net4.7/OneOf
# rm -rf samples/client/petstore/csharp/generichost/net4.7/Petstore
# rm -rf samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate
# - name: Generate samples
# run: |
# bash bin/generate-samples.sh
# # when a sample is deleted, you have to generate it twice for all files to get created
# bash bin/generate-samples.sh
# - name: Verify git status
# run: |
# if [[ "$(git status --porcelain)" != "" ]]; then
# echo "UNCOMMITTED CHANGES ERROR"
# echo "There are uncommitted changes in working tree after execution of 'bin/generate-samples.sh'"
# echo "Perform git diff"
# git --no-pager diff
# echo "Perform git status"
# git status
# echo -e "\nThis script runs in pull requests against the anticipated merge commit (as if the PR was merged now)."
# echo "When you see unexpected files here, it likely means that there are newer commits in master that you need to "
# echo -e "rebase or merge into your branch.\n"
# echo "Please run 'bin/generate-samples.sh' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
# exit 1
# fi
6 changes: 6 additions & 0 deletions bin/configs/tidal-kotlin-petstore-new.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generatorName: tidal-kotlin
outputDir: samples/client/petstore/tidal/kotlin
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/tidal-kotlin
additionalProperties:
hideGenerationTimestamp: "true"
Loading
Loading