Skip to content

Commit 879abcd

Browse files
committed
Merge branch 'master' into feature/add-enum-validation-for-pageable
2 parents 323adf1 + e6c830e commit 879abcd

93 files changed

Lines changed: 588 additions & 246 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.

.github/workflows/samples-julia.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v5
19-
- uses: julia-actions/setup-julia@v2
19+
- uses: julia-actions/setup-julia@v3
2020
with:
2121
version: 1.8
2222
arch: x64

README.md

Lines changed: 42 additions & 39 deletions
Large diffs are not rendered by default.

docs/installation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ export JAVA_HOME=`/usr/libexec/java_home -v 1.11`
143143
export PATH=${JAVA_HOME}/bin:$PATH
144144
```
145145

146+
## JBang
147+
148+
> **Platform(s)**: Linux, macOS, Windows
149+
150+
Use [JBang](https://www.jbang.dev/) to retrieve and run the JAR file using Maven coordinates.
151+
152+
Run `jbang --java 11 org.openapitools:openapi-generator-cli:LATEST help` to show the usage.
153+
146154
## Bash Launcher Script
147155

148156
> **Platform(s)**: Linux, macOS, Windows (variable)

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,46 @@ public String toEnumValue(String value, String datatype) {
781781
}
782782
}
783783

784+
/**
785+
* Builds the PHP expression for a backed enum case default (PHP 8.1+ {@code enum}).
786+
* <p>
787+
* The legacy {@code self::}{@code <datatype>_<CASE>} form came from class-constant style enums (#10273) and is
788+
* invalid when {@code datatype} is a namespaced class: {@code self::} only resolves constants on the current
789+
* class. Native enums must use {@code EnumType::CASE}.
790+
* <p>
791+
* Execution: {@code datatype} is produced upstream (e.g. {@link DefaultCodegen#updateCodegenPropertyEnum}) via
792+
* {@link #getTypeDeclaration(Schema)} for the referenced enum schema; {@code value} is the sanitized case name
793+
* from {@link #toEnumVarName}. When the enum class sits under {@link #modelPackage}, we emit only the short class
794+
* name plus {@code ::} so it matches sibling model references in generated files ({@code namespace} is
795+
* {@code modelPackage}; unqualified names resolve correctly). A fully qualified body without a leading
796+
* {@code \} would be resolved relative to the file namespace and is invalid PHP for defaults.
797+
*
798+
* @param value enum case name (e.g. {@code AVAILABLE})
799+
* @param datatype enum class as produced by {@link #getTypeDeclaration(Schema)} (may include {@code modelPackage})
800+
* @return PHP default expression for that case (e.g. {@code PetStatus::AVAILABLE})
801+
*/
784802
@Override
785803
public String toEnumDefaultValue(String value, String datatype) {
786-
return "self::" + datatype + "_" + value;
804+
return unqualifiedEnumClassForModelDefault(datatype) + "::" + value;
805+
}
806+
807+
/**
808+
* Strips {@link #modelPackage} from a declared enum class name so defaults use the same unqualified form as
809+
* property type hints in model templates.
810+
*
811+
* @param datatype enum class string from codegen (optional leading {@code \})
812+
* @return short class name if under {@code modelPackage}, otherwise the original {@code datatype}
813+
*/
814+
private String unqualifiedEnumClassForModelDefault(String datatype) {
815+
if (StringUtils.isBlank(datatype) || StringUtils.isBlank(modelPackage)) {
816+
return datatype;
817+
}
818+
String normalized = datatype.charAt(0) == '\\' ? datatype.substring(1) : datatype;
819+
String prefix = modelPackage + "\\";
820+
if (normalized.startsWith(prefix)) {
821+
return normalized.substring(prefix.length());
822+
}
823+
return datatype;
787824
}
788825

789826
@Override

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
238238
/**
239239
* Set the instance that matches the anyOf child schema, check
240240
* the instance parameter is valid against the anyOf child schemas:
241-
* {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}
241+
* {{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}
242242
*
243243
* It could be an instance of the 'anyOf' schemas.
244244
*/
@@ -276,9 +276,9 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
276276

277277
/**
278278
* Get the actual instance, which can be the following:
279-
* {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}
279+
* {{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}
280280
*
281-
* @return The actual instance ({{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}})
281+
* @return The actual instance ({{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}})
282282
*/
283283
@SuppressWarnings("unchecked")
284284
@Override
@@ -290,11 +290,11 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
290290
{{#anyOf}}
291291
{{^vendorExtensions.x-duplicated-data-type-ignoring-erasure}}
292292
/**
293-
* Get the actual instance of `{{{dataType}}}`. If the actual instance is not `{{{dataType}}}`,
293+
* Get the actual instance of `{{dataType}}`. If the actual instance is not `{{dataType}}`,
294294
* the ClassCastException will be thrown.
295295
*
296-
* @return The actual instance of `{{{dataType}}}`
297-
* @throws ClassCastException if the instance is not `{{{dataType}}}`
296+
* @return The actual instance of `{{dataType}}`
297+
* @throws ClassCastException if the instance is not `{{dataType}}`
298298
*/
299299
public {{{dataType}}} get{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}() throws ClassCastException {
300300
return ({{{dataType}}})super.getActualInstance();

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
316316
/**
317317
* Set the instance that matches the oneOf child schema, check
318318
* the instance parameter is valid against the oneOf child schemas:
319-
* {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}
319+
* {{#oneOf}}{{.}}{{^-last}}, {{/-last}}{{/oneOf}}
320320
*
321321
* It could be an instance of the 'oneOf' schemas.
322322
*/
@@ -354,9 +354,9 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
354354

355355
/**
356356
* Get the actual instance, which can be the following:
357-
* {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}
357+
* {{#oneOf}}{{.}}{{^-last}}, {{/-last}}{{/oneOf}}
358358
*
359-
* @return The actual instance ({{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}})
359+
* @return The actual instance ({{#oneOf}}{{.}}{{^-last}}, {{/-last}}{{/oneOf}})
360360
*/
361361
@SuppressWarnings("unchecked")
362362
@Override
@@ -368,12 +368,13 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
368368
{{#oneOf}}
369369
{{^vendorExtensions.x-duplicated-data-type-ignoring-erasure}}
370370
/**
371-
* Get the actual instance of `{{{dataType}}}`. If the actual instance is not `{{{dataType}}}`,
371+
* Get the actual instance of `{{dataType}}`. If the actual instance is not `{{dataType}}`,
372372
* the ClassCastException will be thrown.
373373
*
374-
* @return The actual instance of `{{{dataType}}}`
375-
* @throws ClassCastException if the instance is not `{{{dataType}}}`
374+
* @return The actual instance of `{{dataType}}`
375+
* @throws ClassCastException if the instance is not `{{dataType}}`
376376
*/
377+
@SuppressWarnings("unchecked")
377378
public {{{dataType}}} get{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}() throws ClassCastException {
378379
return ({{{dataType}}})super.getActualInstance();
379380
}

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>org.springframework.cloud</groupId>
6060
<artifactId>spring-cloud-starter-parent</artifactId>
61-
<version>2023.0.0</version>
61+
<version>2023.0.6</version>
6262
<type>pom</type>
6363
<scope>import</scope>
6464
</dependency>

modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ plugins {
2424
id("org.jetbrains.kotlin.jvm") version kotlinVersion
2525
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
2626
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
27-
id("org.springframework.boot") version "3.0.2"
28-
id("io.spring.dependency-management") version "1.0.14.RELEASE"
27+
id("org.springframework.boot") version "3.3.13"
28+
id("io.spring.dependency-management") version "1.1.7"
2929
}
3030

3131
dependencies {

modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>org.springframework.boot</groupId>
2323
<artifactId>spring-boot-starter-parent</artifactId>
24-
<version>3.1.3</version>
24+
<version>3.3.13</version>
2525
</parent>
2626
<repositories>
2727
<repository>

modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb3-Kts.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ plugins {
1818
id("org.jetbrains.kotlin.jvm") version kotlinVersion
1919
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
2020
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
21-
id("org.springframework.boot") version "3.0.2"
22-
id("io.spring.dependency-management") version "1.0.14.RELEASE"
21+
id("org.springframework.boot") version "3.3.13"
22+
id("io.spring.dependency-management") version "1.1.7"
2323
}
2424

2525
tasks.getByName("bootJar") {
@@ -32,7 +32,7 @@ tasks.getByName("jar") {
3232

3333
dependencyManagement {
3434
imports {
35-
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
35+
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2023.0.6")
3636
}
3737
}
3838

@@ -58,7 +58,7 @@ dependencies {
5858
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
5959

6060
implementation("org.springframework.cloud:spring-cloud-starter-openfeign"){{#hasAuthMethods}}
61-
implementation("org.springframework.cloud:spring-cloud-starter-oauth2:2.2.5.RELEASE"){{/hasAuthMethods}}
61+
implementation("org.springframework.boot:spring-boot-starter-oauth2-client"){{/hasAuthMethods}}
6262

6363
{{#useBeanValidation}}
6464
implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}

0 commit comments

Comments
 (0)