Skip to content

Commit 0d0b804

Browse files
Merge branch 'master' into fix-resttemplate-without-jakartaee
2 parents 8fd33f8 + 623463a commit 0d0b804

File tree

61 files changed

+3566
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3566
-5
lines changed

.github/workflows/samples-java-client-jdk17.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ on:
77
- samples/client/petstore/java/webclient-jakarta/**
88
- samples/client/petstore/java/restclient-*/**
99
- samples/client/petstore/java/webclient-useSingleRequestParameter/**
10+
- samples/client/others/java/restclient-enum-in-multipart/**
1011
pull_request:
1112
paths:
1213
- samples/client/petstore/java/resttemplate-jakarta/**
1314
- samples/client/petstore/java/webclient-jakarta/**
1415
- samples/client/petstore/java/restclient-*/**
1516
- samples/client/petstore/java/webclient-useSingleRequestParameter/**
17+
- samples/client/others/java/restclient-enum-in-multipart/**
1618
jobs:
1719
build:
1820
name: Build Java Client JDK17
@@ -30,6 +32,7 @@ jobs:
3032
- samples/client/petstore/java/restclient-useSingleRequestParameter
3133
- samples/client/petstore/java/restclient-useSingleRequestParameter-static
3234
- samples/client/petstore/java/webclient-useSingleRequestParameter
35+
- samples/client/others/java/restclient-enum-in-multipart
3336
steps:
3437
- uses: actions/checkout@v4
3538
- uses: actions/setup-java@v4

.github/workflows/samples-python-petstore.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ on:
88
- .github/workflows/samples-python-petstore.yaml
99

1010
jobs:
11+
validate-pyproject-toml:
12+
name: Validate pyproject.toml
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.13"
19+
- name: Install validator
20+
run: pip install 'validate-pyproject[all]'
21+
- name: Validate
22+
run: validate-pyproject samples/openapi3/client/petstore/python/pyproject.toml
1123
build:
1224
name: Test Python client
1325
runs-on: ubuntu-latest
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
generatorName: java
2+
outputDir: samples/client/others/java/restclient-enum-in-multipart
3+
library: restclient
4+
inputSpec: modules/openapi-generator/src/test/resources/3_1/enum-in-multipart.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
hideGenerationTimestamp: "true"

modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,18 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
685685
addCookiesToRequest(cookieParams, requestBuilder);
686686
addCookiesToRequest(defaultCookies, requestBuilder);
687687
688+
if (MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType)) {
689+
formParams.forEach(
690+
(k, v) -> {
691+
if (v instanceof java.util.ArrayList) {
692+
Object o = v.get(0);
693+
if (o != null && o.getClass().getEnumConstants() != null) {
694+
v.set(0, o.toString());
695+
}
696+
}
697+
});
698+
}
699+
688700
var selectedBody = selectBody(body, formParams, contentType);
689701
if (selectedBody != null) {
690702
requestBuilder.body(selectedBody);

modules/openapi-generator/src/main/resources/python/pyproject.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pydantic = ">= 2"
4343
typing-extensions = ">= 4.7.1"
4444
{{/poetry1}}
4545
{{^poetry1}}
46-
requires-python = "^3.9"
46+
requires-python = ">=3.9"
4747

4848
dependencies = [
4949
"urllib3 (>=2.1.0,<3.0.0)",
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
openapi: 3.1.0
2+
info:
3+
description: API
4+
title: API
5+
version: 1.0.0
6+
servers:
7+
- description: "Localhost, used when testing"
8+
url: http://localhost:8080
9+
security:
10+
- basicAuth: []
11+
paths:
12+
/messages:
13+
post:
14+
description: Creates a new message
15+
x-content-type: multipart/form-data
16+
x-accepts:
17+
- application/json
18+
operationId: CreateMessage
19+
requestBody:
20+
$ref: "#/components/requestBodies/CreateMessageBody"
21+
responses:
22+
"201":
23+
$ref: "#/components/responses/MessageCreatedResponse"
24+
summary: Creates a new message
25+
tags:
26+
- BAS
27+
components:
28+
parameters:
29+
messageId:
30+
description: The identifier the message
31+
explode: false
32+
in: path
33+
name: messageId
34+
required: true
35+
schema:
36+
format: uuid
37+
type: string
38+
style: simple
39+
requestBodies:
40+
CreateMessageBody:
41+
content:
42+
multipart/form-data:
43+
schema:
44+
$ref: "#/components/schemas/CreateMessage_request"
45+
required: true
46+
responses:
47+
MessageCreatedResponse:
48+
content:
49+
application/json:
50+
schema:
51+
$ref: "#/components/schemas/inline_object"
52+
description: The message was created.
53+
schemas:
54+
DataDirection:
55+
description: The direction a message travels
56+
enum:
57+
- INGOING
58+
- OUTGOING
59+
type: string
60+
DataChannel:
61+
description: The transport-channel
62+
enum:
63+
- BIKE
64+
- CAR
65+
- BUS
66+
- PLANE
67+
type: string
68+
messageId:
69+
description: The messageID
70+
format: uuid
71+
type: string
72+
CreateMessage_request:
73+
properties:
74+
fileContent:
75+
description: The message payload
76+
format: binary
77+
type: string
78+
idempotencyKey:
79+
type: string
80+
dataDirection:
81+
$ref: "#/components/schemas/DataDirection"
82+
dataChannel:
83+
$ref: "#/components/schemas/DataChannel"
84+
required:
85+
- dataChannel
86+
- dataDirection
87+
- fileContent
88+
- fileType
89+
- idempotencyKey
90+
type: object
91+
inline_object:
92+
example:
93+
messageId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
94+
properties:
95+
messageId:
96+
description: The messageID
97+
format: uuid
98+
type: string
99+
required:
100+
- messageId
101+
securitySchemes:
102+
basicAuth:
103+
scheme: basic
104+
type: http
105+

samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,18 @@ protected RestClient.RequestBodySpec prepareRequest(String path, HttpMethod meth
639639
addCookiesToRequest(cookieParams, requestBuilder);
640640
addCookiesToRequest(defaultCookies, requestBuilder);
641641

642+
if (MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType)) {
643+
formParams.forEach(
644+
(k, v) -> {
645+
if (v instanceof java.util.ArrayList) {
646+
Object o = v.get(0);
647+
if (o != null && o.getClass().getEnumConstants() != null) {
648+
v.set(0, o.toString());
649+
}
650+
}
651+
});
652+
}
653+
642654
var selectedBody = selectBody(body, formParams, contentType);
643655
if (selectedBody != null) {
644656
requestBuilder.body(selectedBody);

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
license = "Apache 2.0"
99
readme = "README.md"
1010
keywords = ["OpenAPI", "OpenAPI-Generator", "Echo Server API"]
11-
requires-python = "^3.9"
11+
requires-python = ">=3.9"
1212

1313
dependencies = [
1414
"urllib3 (>=2.1.0,<3.0.0)",

samples/client/echo_api/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
license = "Apache 2.0"
99
readme = "README.md"
1010
keywords = ["OpenAPI", "OpenAPI-Generator", "Echo Server API"]
11-
requires-python = "^3.9"
11+
requires-python = ">=3.9"
1212

1313
dependencies = [
1414
"urllib3 (>=2.1.0,<3.0.0)",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
#
4+
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
5+
6+
name: Java CI with Maven
7+
8+
on:
9+
push:
10+
branches: [ main, master ]
11+
pull_request:
12+
branches: [ main, master ]
13+
14+
jobs:
15+
build:
16+
name: Build API
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
java: [ 17, 21 ]
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up JDK
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: ${{ matrix.java }}
27+
distribution: 'temurin'
28+
cache: maven
29+
- name: Build with Maven
30+
run: mvn -B package --no-transfer-progress --file pom.xml

0 commit comments

Comments
 (0)