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

Java anyof oneof #58

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
${{ runner.os }}-gradle-

- name: Setup Maven
uses: s4u/setup-maven-action@v1.14.0
uses: s4u/setup-maven-action@v1.15.0
with:
java-version: ${{ matrix.java }}
maven-version: 3.8.8
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Maven
uses: s4u/setup-maven-action@v1.14.0
uses: s4u/setup-maven-action@v1.15.0
with:
java-version: 11
maven-version: 3.8.8
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/samples-java-client-jdk11.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/**
- samples/openapi3/client/petstore/java/native**
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/okhttp-gson-oneOf-array/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
Expand All @@ -26,6 +27,7 @@ on:
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/**
- samples/openapi3/client/petstore/java/native**
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/okhttp-gson-oneOf-array/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
Expand Down Expand Up @@ -75,6 +77,7 @@ jobs:
- samples/client/petstore/java/resttemplate-swagger2/
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/
- samples/client/others/java/okhttp-gson-oneOf/
- samples/client/others/java/okhttp-gson-oneOf-array/
- samples/client/echo_api/java/okhttp-gson-user-defined-templates/
- samples/client/others/java/resttemplate-useAbstractionForFiles/
- samples/client/others/java/webclient-useAbstractionForFiles/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
- name: Setup Maven
uses: s4u/setup-maven-action@v1.14.0
uses: s4u/setup-maven-action@v1.15.0
with:
java-version: ${{ matrix.java }}
maven-version: 3.8.8
Expand Down
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,17 @@ after_success:
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
fi;
fi;
# publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
#- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
# cd website;
# git config --global user.name "${GH_NAME}";
# git config --global user.email "${GH_EMAIL}";
# echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
# yarn install;
# GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
# fi;
publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-client.md
sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-server.md
cd website;
git config --global user.name "${GH_NAME}";
git config --global user.email "${GH_EMAIL}";
echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
yarn install;
GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
fi;

env:
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
Expand Down
1 change: 1 addition & 0 deletions CI/circle_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ else
(cd samples/client/petstore/java/jersey2-java8 && mvn integration-test)
(cd samples/openapi3/client/petstore/java/jersey2-java8 && mvn integration-test)
(cd samples/client/petstore/java/jersey3 && mvn integration-test)
(cd samples/client/petstore/java/jersey3-oneOf && mvn integration-test)
(cd samples/client/others/java/okhttp-gson-streaming && mvn integration-test)
(cd samples/client/petstore/java/okhttp-gson && mvn integration-test)
(cd samples/client/petstore/java/okhttp-gson-3.1 && mvn integration-test)
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div align="center">

[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.9.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.10.0`):
[![Build Status](https://api.travis-ci.com/OpenAPITools/openapi-generator.svg?branch=master&status=passed)](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
Expand Down Expand Up @@ -129,7 +129,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20

| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.9.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.9.0-SNAPSHOT/) | 07.10.2024 | Minor release with breaking changes (with fallback) |
| 7.10.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.10.0-SNAPSHOT/) | 07.11.2024 | Minor release with breaking changes (with fallback) |
| [7.9.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.9.0) (latest stable release) | 07.10.2024 | Minor release with breaking changes (with fallback) |
| [7.8.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.8.0) (latest stable release) | 19.08.2024 | Minor release with breaking changes (with fallback) |
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with fallback) |
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
Expand Down Expand Up @@ -193,16 +194,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):

JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar`

For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar -O openapi-generator-cli.jar
```

For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar
```

After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
Expand Down Expand Up @@ -437,7 +438,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"

```sh
openapi-generator-cli version-manager set 7.8.0
openapi-generator-cli version-manager set 7.9.0
```

Or install it as dev-dependency:
Expand All @@ -464,7 +465,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)

<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar)
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar)
<!-- /RELEASE_VERSION -->

To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
Expand Down
7 changes: 7 additions & 0 deletions bin/configs/java-jersey3-oneOf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: java
outputDir: samples/client/petstore/java/jersey3-oneOf
library: jersey3
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_additionalProperties.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: true
8 changes: 8 additions & 0 deletions bin/configs/java-okhttp-gson-oneOf-array.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: java
outputDir: samples/client/others/java/okhttp-gson-oneOf-array
library: okhttp-gson
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_array.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"
useBeanValidation: "true"
1 change: 1 addition & 0 deletions docs/generators/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>if</li>
<li>inline</li>
<li>int</li>
<li>linux</li>
<li>long</li>
<li>mutable</li>
<li>namespace</li>
Expand Down
8 changes: 4 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
To install a specific version of the tool, pass the version during installation:
<!-- RELEASE_VERSION -->
```bash
openapi-generator-cli version-manager set 7.8.0
openapi-generator-cli version-manager set 7.9.0
```
<!-- /RELEASE_VERSION -->
To install the tool as a dev dependency in your current project:
Expand Down Expand Up @@ -103,18 +103,18 @@ docker run --rm \
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):

JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar`

For **Mac/Linux** users:

```bash
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar -O openapi-generator-cli.jar
```

For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.

```powershell
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar
```
<!-- /RELEASE_VERSION -->

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.8.0</version>
<version>7.9.0</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.9.0-SNAPSHOT
openApiGeneratorVersion=7.10.0-SNAPSHOT
# /RELEASE_VERSION

# BEGIN placeholders
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.9.0-SNAPSHOT
openApiGeneratorVersion=7.10.0-SNAPSHOT
# /RELEASE_VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/examples/kotlin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/examples/spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-online/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.9.0-SNAPSHOT</version>
<version>7.10.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3158,7 +3158,7 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
additionalPropertiesIsAnyType = true;
}
} else {
// if additioanl properties is set (e.g. free form object, any type, string, etc)
// if additional properties is set (e.g. free form object, any type, string, etc)
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
additionalPropertiesIsAnyType = true;
}
Expand Down Expand Up @@ -8444,6 +8444,7 @@ private List<CodegenProperty> getComposedProperties(List<Schema> xOfCollection,
}
List<CodegenProperty> xOf = new ArrayList<>();
Set<String> dataTypeSet = new HashSet<>(); // to keep track of dataType
Set<String> dataTypeSetIgnoringErasure = new HashSet<>();
int i = 0;
for (Schema xOfSchema : xOfCollection) {
CodegenProperty cp = fromProperty(collectionName + "_" + i, xOfSchema, false);
Expand All @@ -8452,7 +8453,7 @@ private List<CodegenProperty> getComposedProperties(List<Schema> xOfCollection,

if (dataTypeSet.contains(cp.dataType)
|| (isTypeErasedGenerics() && dataTypeSet.contains(cp.baseType))) {
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
// add "x-duplicated-data-type" to indicate if the (base) dataType already occurs before
// in other sub-schemas of allOf/anyOf/oneOf
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type", true);
} else {
Expand All @@ -8462,6 +8463,13 @@ private List<CodegenProperty> getComposedProperties(List<Schema> xOfCollection,
dataTypeSet.add(cp.dataType);
}
}
if (dataTypeSetIgnoringErasure.contains(cp.dataType)) {
// add "x-duplicated-data-type-ignoring-erasure" to indicate if the dataType already occurs before
// in other sub-schemas of allOf/anyOf/oneOf
cp.vendorExtensions.putIfAbsent("x-duplicated-data-type-ignoring-erasure", true);
} else {
dataTypeSetIgnoringErasure.add(cp.dataType);
}
}
return xOf;
}
Expand Down
Loading
Loading