Skip to content

Commit b4a4a66

Browse files
author
jpfinne
committed
Merge remote-tracking branch 'origin/master' into feature/jspecify
# Conflicts: # modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
2 parents b1148fb + 6332eab commit b4a4a66

5,923 files changed

Lines changed: 28524 additions & 24632 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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Samples C# .Net 10 Client (Petstore)
2+
3+
on:
4+
push:
5+
paths:
6+
- samples/client/petstore/csharp/restsharp/net10/Petstore/**
7+
pull_request:
8+
paths:
9+
- samples/client/petstore/csharp/restsharp/net10/Petstore/**
10+
jobs:
11+
build:
12+
name: Build clients
13+
runs-on: ubuntu-latest
14+
services:
15+
petstore-api:
16+
image: swaggerapi/petstore
17+
ports:
18+
- 80:8080
19+
env:
20+
SWAGGER_HOST: http://petstore.swagger.io
21+
SWAGGER_BASE_PATH: /v2
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
sample:
26+
- samples/client/petstore/csharp/restsharp/net10/Petstore/
27+
steps:
28+
- uses: actions/checkout@v5
29+
- uses: actions/setup-dotnet@v5.2.0
30+
with:
31+
dotnet-version: '10.0.x'
32+
- name: Build
33+
working-directory: ${{ matrix.sample }}
34+
run: dotnet build Org.OpenAPITools.sln
35+
- name: Test
36+
working-directory: ${{ matrix.sample }}
37+
run: dotnet test Org.OpenAPITools.sln
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# for .net standard
2+
generatorName: csharp
3+
library: restsharp
4+
outputDir: samples/client/petstore/csharp/restsharp/net10/EnumMappings
5+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
6+
templateDir: modules/openapi-generator/src/main/resources/csharp
7+
additionalProperties:
8+
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
9+
useCompareNetObjects: true
10+
disallowAdditionalPropertiesIfNotPresent: false
11+
useOneOfDiscriminatorLookup: true
12+
targetFramework: net10.0
13+
equatable: true
14+
enumNameMappings:
15+
delivered: Shipped
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# for .net standard
22
generatorName: csharp
33
library: restsharp
4-
outputDir: samples/client/petstore/csharp/restsharp/net10/EnumMappings
5-
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
4+
outputDir: samples/client/petstore/csharp/restsharp/net10/Petstore
5+
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types-localhost.yaml
66
templateDir: modules/openapi-generator/src/main/resources/csharp
77
additionalProperties:
88
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
@@ -11,5 +11,3 @@ additionalProperties:
1111
useOneOfDiscriminatorLookup: true
1212
targetFramework: net10.0
1313
equatable: true
14-
enumNameMappings:
15-
delivered: Shipped

modules/openapi-generator-gradle-plugin/pom.xml

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,24 @@
9999
<arg>-Psigning.secretKeyRingFile=${env.TRAVIS_BUILD_DIR}/sec.gpg</arg>
100100
-->
101101
</args>
102+
<!-- Force the Gradle daemon to use the same JVM Maven is running with.
103+
This prevents Gradle from picking up a system-level JDK (e.g. JDK 25)
104+
when Maven is configured to run on a different JDK (e.g. JDK 21). -->
105+
<jvmArgs>
106+
<jvmArg>-Dorg.gradle.java.home=${java.home}</jvmArg>
107+
</jvmArgs>
102108
</configuration>
103109
<executions>
104110
<execution>
111+
<id>gradle-build</id>
105112
<phase>install</phase>
106113
<goals>
107114
<!-- goal must be "invoke" -->
108115
<goal>invoke</goal>
109116
</goals>
110117
<configuration>
111118
<tasks>
112-
<!-- calls "clean assemble install" -->
119+
<!-- calls "clean build publishToMavenLocal" (build includes tests) -->
113120
<task>clean</task>
114121
<task>build</task>
115122
<task>publishToMavenLocal</task>
@@ -122,6 +129,83 @@
122129
</build>
123130

124131
<profiles>
132+
<profile>
133+
<id>skip-gradle-tests</id>
134+
<activation>
135+
<property>
136+
<name>maven.test.skip</name>
137+
<value>true</value>
138+
</property>
139+
</activation>
140+
<build>
141+
<plugins>
142+
<plugin>
143+
<groupId>org.fortasoft</groupId>
144+
<artifactId>gradle-maven-plugin</artifactId>
145+
<executions>
146+
<!-- Override the gradle-build execution: keep `build` (so checkstyle,
147+
spotbugs, and other check-lifecycle tasks still run) but add
148+
`-x test` to exclude only the Gradle test task, mirroring
149+
Maven's maven.test.skip behaviour which does not skip quality checks. -->
150+
<execution>
151+
<id>gradle-build</id>
152+
<configuration>
153+
<args combine.children="append">
154+
<arg>-x</arg>
155+
<arg>test</arg>
156+
</args>
157+
<tasks>
158+
<task>clean</task>
159+
<task>build</task>
160+
<task>publishToMavenLocal</task>
161+
</tasks>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
</profile>
169+
<profile>
170+
<id>skip-gradle-tests-skipTests</id>
171+
<activation>
172+
<property>
173+
<name>skipTests</name>
174+
<!-- Maven maps bare -DskipTests to the string "true", so this matches
175+
both -DskipTests and -DskipTests=true but NOT -DskipTests=false. -->
176+
<value>true</value>
177+
</property>
178+
</activation>
179+
<build>
180+
<plugins>
181+
<plugin>
182+
<groupId>org.fortasoft</groupId>
183+
<artifactId>gradle-maven-plugin</artifactId>
184+
<executions>
185+
<!-- Override the gradle-build execution: keep `build` (so checkstyle,
186+
spotbugs, and other check-lifecycle tasks still run) but add
187+
`-x test` to exclude only the Gradle test task.
188+
combine.children="append" appends to the plugin-level <args>
189+
instead of replacing them, preserving -P openApiGeneratorVersion. -->
190+
<execution>
191+
<id>gradle-build</id>
192+
<configuration>
193+
<args combine.children="append">
194+
<arg>-x</arg>
195+
<arg>test</arg>
196+
</args>
197+
<tasks>
198+
<task>clean</task>
199+
<task>build</task>
200+
<task>publishToMavenLocal</task>
201+
</tasks>
202+
</configuration>
203+
</execution>
204+
</executions>
205+
</plugin>
206+
</plugins>
207+
</build>
208+
</profile>
125209
<profile>
126210
<id>static-analysis</id>
127211
<build>

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,13 @@ public void processOpts() {
864864
additionalProperties.put("feign-okhttp", "true");
865865
} else if (isLibrary(FEIGN_HC5)) {
866866
additionalProperties.put("feign-hc5", "true");
867-
setTemplateDir(FEIGN);
867+
// Only fall back to the built-in "feign" template directory when the user has not
868+
// provided a custom template directory. super.processOpts() already wrote any
869+
// user-supplied templateDir back into additionalProperties, so checking for the
870+
// key's presence reliably distinguishes "user provided" from "not provided".
871+
if (!additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR)) {
872+
setTemplateDir(FEIGN);
873+
}
868874
setLibrary(FEIGN);
869875
}
870876

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import com.fasterxml.jackson.core.JsonProcessingException;
5+
import com.fasterxml.jackson.core.io.JsonStringEncoder;
56
import com.fasterxml.jackson.databind.JsonNode;
67
import com.fasterxml.jackson.databind.ObjectMapper;
78
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -332,8 +333,8 @@ public void addToMap(CodegenOperation codegenOperation) {
332333
}
333334
}
334335

335-
tagName = formatDescription(tagName);
336-
tagDescription = formatDescription(tagDescription);
336+
tagName = escapeJsonString(tagName);
337+
tagDescription = escapeJsonString(tagDescription);
337338

338339
PostmanRequestFolder folder = new PostmanRequestFolder(tagName, tagDescription);
339340
List<CodegenOperation> list = codegenOperationsByTag.get(folder);
@@ -685,6 +686,13 @@ public String formatDescription(String description) {
685686
return description;
686687
}
687688

689+
String escapeJsonString(String value) {
690+
if (value == null) {
691+
return null;
692+
}
693+
return new String(JsonStringEncoder.getInstance().quoteAsString(value));
694+
}
695+
688696
/**
689697
* Extract all placeholders (string delimited by curly braces ie {{PLACEHOLDER}}) from the input string
690698
*

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4ClientCodegen.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.openapitools.codegen.languages;
218

319
import io.swagger.v3.oas.models.Operation;
@@ -155,7 +171,8 @@ public void processOpts() {
155171
supportingFiles.add(new SupportingFile("jsonSupport.mustache", invokerFolder, "JsonSupport.scala"));
156172
supportingFiles.add(new SupportingFile("additionalTypeSerializers.mustache", invokerFolder, "AdditionalTypeSerializers.scala"));
157173
supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
158-
supportingFiles.add(new SupportingFile("dateSerializers.mustache", invokerFolder, "DateSerializers.scala"));
174+
supportingFiles.add(new SupportingFile("project/plugins.mustache", "project", "plugins.sbt"));
175+
supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf"));
159176
}
160177

161178
@Override

modules/openapi-generator/src/main/resources/Java/libraries/feign/pojo.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
318318
* (except the first line).
319319
*/
320320
private{{#jsonb}} static{{/jsonb}} String toIndentedString(Object o) {
321-
if (o == null) {
322-
return "null";
323-
}
324-
return o.toString().replace("\n", "\n ");
321+
return o == null ? "null" : o.toString().replace("\n", "\n ");
325322
}
326323
{{#supportUrlQuery}}
327324

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ public abstract class AbstractOpenApiSchema {
9797
* (except the first line).
9898
*/
9999
private String toIndentedString(Object o) {
100-
if (o == null) {
101-
return "null";
102-
}
103-
return o.toString().replace("\n", "\n ");
100+
return o == null ? "null" : o.toString().replace("\n", "\n ");
104101
}
105102

106103
public boolean equals(Object o) {

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
338338
* (except the first line).
339339
*/
340340
private String toIndentedString(Object o) {
341-
if (o == null) {
342-
return "null";
343-
}
344-
return o.toString().replace("\n", "\n ");
341+
return o == null ? "null" : o.toString().replace("\n", "\n ");
345342
}
346343
347344
{{#parcelableModel}}

0 commit comments

Comments
 (0)