-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[java][spring-clients]Bugfix: additional properties in multipart request #22574
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
Open
sermler
wants to merge
7
commits into
OpenAPITools:master
Choose a base branch
from
sermler:bugfix/additional-properties-in-multipart-request-java-resttemplate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e6eb7d
Add test-case for additional-properties-in-multipart-issue-java-restt…
sermler dcf1f08
Fix multipart requests for additional-properties
sermler 80f16fe
Update samples
sermler 5cafdb3
Move sample-spec to java folder
sermler 3b6ece2
Add additional reproduction samples
sermler 45dacf7
Fix multipart requests for container types (restclient)
sermler 8ed23de
Fix multipart requests for container types (webclient)
sermler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
bin/configs/java-restclient-additonal-properties-in-multipart-request-issue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: java | ||
| outputDir: samples/client/others/java/restclient-additonal-properties-in-multipart-request-issue | ||
| library: restclient | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/java/additonal-properties-in-multipart-request-issue.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/Java | ||
| additionalProperties: | ||
| artifactId: additonal-properties-in-multipart-request-issue | ||
| hideGenerationTimestamp: "true" | ||
| java8: true | ||
9 changes: 9 additions & 0 deletions
9
bin/configs/java-resttemplate-additonal-properties-in-multipart-request-issue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: java | ||
| outputDir: samples/client/others/java/resttemplate-additonal-properties-in-multipart-request-issue | ||
| library: resttemplate | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/java/additonal-properties-in-multipart-request-issue.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/Java | ||
| additionalProperties: | ||
| artifactId: additonal-properties-in-multipart-request-issue | ||
| hideGenerationTimestamp: "true" | ||
| java8: true |
9 changes: 9 additions & 0 deletions
9
bin/configs/java-webclient-additonal-properties-in-multipart-request-issue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: java | ||
| outputDir: samples/client/others/java/webclient-additonal-properties-in-multipart-request-issue | ||
| library: webclient | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/java/additonal-properties-in-multipart-request-issue.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/Java | ||
| additionalProperties: | ||
| artifactId: additonal-properties-in-multipart-request-issue | ||
| hideGenerationTimestamp: "true" | ||
| java8: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...enerator/src/test/resources/3_0/java/additonal-properties-in-multipart-request-issue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| openapi: 3.0.3 | ||
| info: | ||
| title: Minimal | ||
| description: Api to reproduce bug | ||
| version: 0.5.1-SNAPSHOT.0 | ||
| tags: | ||
| - name: test | ||
| servers: | ||
| - url: http://localhost:8080 | ||
| paths: | ||
| "/api/v1/file": | ||
| post: | ||
| tags: | ||
| - file | ||
| operationId: createFile | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| multipart/form-data: | ||
| schema: | ||
| $ref: "#/components/schemas/FileUploadRequest" | ||
| encoding: | ||
| documentBytes: | ||
| contentType: "*/*" | ||
| properties: | ||
| contentType: application/json | ||
| responses: | ||
| "201": | ||
| description: File created successfully | ||
| components: | ||
| schemas: | ||
| FileUploadRequest: | ||
| type: object | ||
| properties: | ||
| documentBytes: | ||
| type: string | ||
| format: binary | ||
| documentType: | ||
| type: string | ||
| structured: | ||
| $ref: '#/components/schemas/StructuredType' | ||
| properties: | ||
| $ref: '#/components/schemas/TypeMap' | ||
| required: | ||
| - documentBytes | ||
| - documentType | ||
| - properties | ||
| TypeMap: | ||
| type: object | ||
| additionalProperties: | ||
| type: string | ||
| StructuredType: | ||
| type: object | ||
| properties: | ||
| someString: | ||
| type: string |
30 changes: 30 additions & 0 deletions
30
...va/restclient-additonal-properties-in-multipart-request-issue/.github/workflows/maven.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
| # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
| # | ||
| # This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) | ||
|
|
||
| name: Java CI with Maven | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, master ] | ||
| pull_request: | ||
| branches: [ main, master ] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Minimal | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| java: [ 17, 21 ] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: ${{ matrix.java }} | ||
| distribution: 'temurin' | ||
| cache: maven | ||
| - name: Build with Maven | ||
| run: mvn -B package --no-transfer-progress --file pom.xml |
21 changes: 21 additions & 0 deletions
21
.../client/others/java/restclient-additonal-properties-in-multipart-request-issue/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| *.class | ||
|
|
||
| # Mobile Tools for Java (J2ME) | ||
| .mtj.tmp/ | ||
|
|
||
| # Package Files # | ||
| *.jar | ||
| *.war | ||
| *.ear | ||
|
|
||
| # exclude jar for gradle wrapper | ||
| !gradle/wrapper/*.jar | ||
|
|
||
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* | ||
|
|
||
| # build files | ||
| **/target | ||
| target | ||
| .gradle | ||
| build |
23 changes: 23 additions & 0 deletions
23
...java/restclient-additonal-properties-in-multipart-request-issue/.openapi-generator-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # Use this file to prevent files from being overwritten by the generator. | ||
| # The patterns follow closely to .gitignore or .dockerignore. | ||
|
|
||
| # As an example, the C# client generator defines ApiClient.cs. | ||
| # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
| #ApiClient.cs | ||
|
|
||
| # You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
| #foo/*/qux | ||
| # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
|
||
| # You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
| #foo/**/qux | ||
| # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
|
||
| # You can also negate patterns with an exclamation (!). | ||
| # For example, you can ignore all files in a docs folder with the file extension .md: | ||
| #docs/*.md | ||
| # Then explicitly reverse the ignore rule for a single file: | ||
| #!docs/README.md |
32 changes: 32 additions & 0 deletions
32
.../java/restclient-additonal-properties-in-multipart-request-issue/.openapi-generator/FILES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| .github/workflows/maven.yml | ||
| .gitignore | ||
| .travis.yml | ||
| README.md | ||
| api/openapi.yaml | ||
| build.gradle | ||
| build.sbt | ||
| docs/FileApi.md | ||
| docs/StructuredType.md | ||
| git_push.sh | ||
| gradle.properties | ||
| gradle/wrapper/gradle-wrapper.jar | ||
| gradle/wrapper/gradle-wrapper.properties | ||
| gradlew | ||
| gradlew.bat | ||
| pom.xml | ||
| settings.gradle | ||
| src/main/AndroidManifest.xml | ||
| src/main/java/org/openapitools/client/ApiClient.java | ||
| src/main/java/org/openapitools/client/JavaTimeFormatter.java | ||
| src/main/java/org/openapitools/client/RFC3339DateFormat.java | ||
| src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java | ||
| src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java | ||
| src/main/java/org/openapitools/client/ServerConfiguration.java | ||
| src/main/java/org/openapitools/client/ServerVariable.java | ||
| src/main/java/org/openapitools/client/StringUtil.java | ||
| src/main/java/org/openapitools/client/api/FileApi.java | ||
| src/main/java/org/openapitools/client/auth/ApiKeyAuth.java | ||
| src/main/java/org/openapitools/client/auth/Authentication.java | ||
| src/main/java/org/openapitools/client/auth/HttpBasicAuth.java | ||
| src/main/java/org/openapitools/client/auth/HttpBearerAuth.java | ||
| src/main/java/org/openapitools/client/model/StructuredType.java |
1 change: 1 addition & 0 deletions
1
...ava/restclient-additonal-properties-in-multipart-request-issue/.openapi-generator/VERSION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.19.0-SNAPSHOT |
22 changes: 22 additions & 0 deletions
22
...client/others/java/restclient-additonal-properties-in-multipart-request-issue/.travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # | ||
| # Generated by OpenAPI Generator: https://openapi-generator.tech | ||
| # | ||
| # Ref: https://docs.travis-ci.com/user/languages/java/ | ||
| # | ||
| language: java | ||
| jdk: | ||
| - openjdk12 | ||
| - openjdk11 | ||
| - openjdk10 | ||
| - openjdk9 | ||
| - openjdk8 | ||
| before_install: | ||
| # ensure gradlew has proper permission | ||
| - chmod a+x ./gradlew | ||
| script: | ||
| # test using maven | ||
| #- mvn test | ||
| # test using gradle | ||
| - gradle test | ||
| # test using sbt | ||
| # - sbt test |
141 changes: 141 additions & 0 deletions
141
...thers/java/restclient-additonal-properties-in-multipart-request-issue/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| # additonal-properties-in-multipart-request-issue | ||
|
|
||
| Minimal | ||
|
|
||
| - API version: 0.5.1-SNAPSHOT.0 | ||
|
|
||
| - Generator version: 7.19.0-SNAPSHOT | ||
|
|
||
| Api to reproduce bug | ||
|
|
||
|
|
||
| *Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* | ||
|
|
||
| ## Requirements | ||
|
|
||
| Building the API client library requires: | ||
|
|
||
| 1. Java 17+ | ||
| 2. Maven/Gradle | ||
|
|
||
| ## Installation | ||
|
|
||
| To install the API client library to your local Maven repository, simply execute: | ||
|
|
||
| ```shell | ||
| mvn clean install | ||
| ``` | ||
|
|
||
| To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: | ||
|
|
||
| ```shell | ||
| mvn clean deploy | ||
| ``` | ||
|
|
||
| Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. | ||
|
|
||
| ### Maven users | ||
|
|
||
| Add this dependency to your project's POM: | ||
|
|
||
| ```xml | ||
| <dependency> | ||
| <groupId>org.openapitools</groupId> | ||
| <artifactId>additonal-properties-in-multipart-request-issue</artifactId> | ||
| <version>0.5.1-SNAPSHOT.0</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| ### Gradle users | ||
|
|
||
| Add this dependency to your project's build file: | ||
|
|
||
| ```groovy | ||
| repositories { | ||
| mavenCentral() // Needed if the 'additonal-properties-in-multipart-request-issue' jar has been published to maven central. | ||
| mavenLocal() // Needed if the 'additonal-properties-in-multipart-request-issue' jar has been published to the local maven repo. | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation "org.openapitools:additonal-properties-in-multipart-request-issue:0.5.1-SNAPSHOT.0" | ||
| } | ||
| ``` | ||
|
|
||
| ### Others | ||
|
|
||
| At first generate the JAR by executing: | ||
|
|
||
| ```shell | ||
| mvn clean package | ||
| ``` | ||
|
|
||
| Then manually install the following JARs: | ||
|
|
||
| - `target/additonal-properties-in-multipart-request-issue-0.5.1-SNAPSHOT.0.jar` | ||
| - `target/lib/*.jar` | ||
|
|
||
| ## Getting Started | ||
|
|
||
| Please follow the [installation](#installation) instruction and execute the following Java code: | ||
|
|
||
| ```java | ||
|
|
||
| import org.openapitools.client.*; | ||
| import org.openapitools.client.auth.*; | ||
| import org.openapitools.client.model.*; | ||
| import org.openapitools.client.api.FileApi; | ||
|
|
||
| public class FileApiExample { | ||
|
|
||
| public static void main(String[] args) { | ||
| ApiClient defaultClient = new ApiClient(); | ||
| defaultClient.setBasePath("http://localhost:8080"); | ||
|
|
||
| FileApi apiInstance = new FileApi(defaultClient); | ||
| File documentBytes = new File("/path/to/file"); // File | | ||
| String documentType = "documentType_example"; // String | | ||
| Map<String, String> properties = new HashMap(); // Map<String, String> | | ||
| StructuredType structured = new StructuredType(); // StructuredType | | ||
| try { | ||
| apiInstance.createFile(documentBytes, documentType, properties, structured); | ||
| } catch (HttpStatusCodeException e) { | ||
| System.err.println("Exception when calling FileApi#createFile"); | ||
| System.err.println("Status code: " + e.getStatusCode().value()); | ||
| System.err.println("Reason: " + e.getResponseBodyAsString()); | ||
| System.err.println("Response headers: " + e.getResponseHeaders()); | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ## Documentation for API Endpoints | ||
|
|
||
| All URIs are relative to *http://localhost:8080* | ||
|
|
||
| Class | Method | HTTP request | Description | ||
| ------------ | ------------- | ------------- | ------------- | ||
| *FileApi* | [**createFile**](docs/FileApi.md#createFile) | **POST** /api/v1/file | | ||
|
|
||
|
|
||
| ## Documentation for Models | ||
|
|
||
| - [StructuredType](docs/StructuredType.md) | ||
|
|
||
|
|
||
| <a id="documentation-for-authorization"></a> | ||
| ## Documentation for Authorization | ||
|
|
||
| Endpoints do not require authorization. | ||
|
|
||
|
|
||
| ## Recommendation | ||
|
|
||
| It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. | ||
|
|
||
| ## Author | ||
|
|
||
|
|
||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the pr
what about adding the new folder to the github workflow so that it will be tested moving forward?
https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-java-client-jdk11.yaml