Skip to content

Commit 5c27a71

Browse files
authored
Merge branch 'swagger-api:master' into chore/sonar-cleanup-no-system-out
2 parents b65ecbf + 8767cea commit 5c27a71

File tree

32 files changed

+107
-74
lines changed

32 files changed

+107
-74
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ The OpenAPI Specification has undergone several revisions since initial creation
2323

2424
Swagger core Version | Release Date | OpenAPI Spec compatibility | Notes | Status
2525
------------------------- | ------------ | -------------------------- | ----- | ----
26-
2.2.37 (**current stable**)| 2025-09-16 | 3.x | [tag v2.2.37](https://github.com/swagger-api/swagger-core/tree/v2.2.37) | Supported
26+
2.2.38 (**current stable**)| 2025-09-29 | 3.x | [tag v2.2.38](https://github.com/swagger-api/swagger-core/tree/v2.2.38) | Supported
27+
2.2.37 | 2025-09-16 | 3.x | [tag v2.2.37](https://github.com/swagger-api/swagger-core/tree/v2.2.37) | Supported
2728
2.2.36 | 2025-08-18 | 3.x | [tag v2.2.36](https://github.com/swagger-api/swagger-core/tree/v2.2.36) | Supported
2829
2.2.35 | 2025-07-31 | 3.x | [tag v2.2.35](https://github.com/swagger-api/swagger-core/tree/v2.2.35) | Supported
2930
2.2.34 | 2025-06-20 | 3.x | [tag v2.2.34](https://github.com/swagger-api/swagger-core/tree/v2.2.34) | Supported
@@ -130,7 +131,7 @@ You need the following installed and available in your $PATH:
130131
* Jackson 2.4.5 or greater
131132

132133

133-
### To build from source (currently 2.2.38-SNAPSHOT)
134+
### To build from source (currently 2.2.39-SNAPSHOT)
134135
```
135136
# first time building locally
136137
mvn -N

modules/swagger-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.core.v3</groupId>
55
<artifactId>swagger-project</artifactId>
6-
<version>2.2.38-SNAPSHOT</version>
6+
<version>2.2.39-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/Schema.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,11 @@
176176

177177
/**
178178
* Allows to specify the required mode (RequiredMode.AUTO, REQUIRED, NOT_REQUIRED)
179-
*
180-
* RequiredMode.AUTO: will let the library decide based on its heuristics.
179+
* RequiredMode.AUTO: the library decides using heuristics:
180+
* - Bean Validation / nullability annotations (@NotNull, @NonNull, @NotBlank, @NotEmpty) - required
181+
* - Optional - not required
182+
* - Primitive types (int, boolean, etc.) - not required unless annotated
183+
* - Other object fields without any constraints - not required
181184
* RequiredMode.REQUIRED: will force the item to be considered as required regardless of heuristics.
182185
* RequiredMode.NOT_REQUIRED: will force the item to be considered as not required regardless of heuristics.
183186
*

modules/swagger-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.core.v3</groupId>
55
<artifactId>swagger-project</artifactId>
6-
<version>2.2.38-SNAPSHOT</version>
6+
<version>2.2.39-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,43 +2132,7 @@ private boolean resolveSubtypes(Schema model, BeanDescription bean, ModelConvert
21322132
ComposedSchema composedSchema = null;
21332133
if (!(subtypeModel instanceof ComposedSchema)) {
21342134
// create composed schema
2135-
// TODO #2312 - smarter way needs clone implemented in #2227
2136-
composedSchema = (ComposedSchema) new ComposedSchema()
2137-
.title(subtypeModel.getTitle())
2138-
.name(subtypeModel.getName())
2139-
.deprecated(subtypeModel.getDeprecated())
2140-
.additionalProperties(subtypeModel.getAdditionalProperties())
2141-
.description(subtypeModel.getDescription())
2142-
.discriminator(subtypeModel.getDiscriminator())
2143-
.exclusiveMaximum(subtypeModel.getExclusiveMaximum())
2144-
.exclusiveMinimum(subtypeModel.getExclusiveMinimum())
2145-
.externalDocs(subtypeModel.getExternalDocs())
2146-
.format(subtypeModel.getFormat())
2147-
.maximum(subtypeModel.getMaximum())
2148-
.maxItems(subtypeModel.getMaxItems())
2149-
.maxLength(subtypeModel.getMaxLength())
2150-
.maxProperties(subtypeModel.getMaxProperties())
2151-
.minimum(subtypeModel.getMinimum())
2152-
.minItems(subtypeModel.getMinItems())
2153-
.minLength(subtypeModel.getMinLength())
2154-
.minProperties(subtypeModel.getMinProperties())
2155-
.multipleOf(subtypeModel.getMultipleOf())
2156-
.not(subtypeModel.getNot())
2157-
.nullable(subtypeModel.getNullable())
2158-
.pattern(subtypeModel.getPattern())
2159-
.properties(subtypeModel.getProperties())
2160-
.readOnly(subtypeModel.getReadOnly())
2161-
.required(subtypeModel.getRequired())
2162-
.type(subtypeModel.getType())
2163-
.uniqueItems(subtypeModel.getUniqueItems())
2164-
.writeOnly(subtypeModel.getWriteOnly())
2165-
.xml(subtypeModel.getXml())
2166-
.extensions(subtypeModel.getExtensions());
2167-
2168-
if (subtypeModel.getExample() != null || subtypeModel.getExampleSetFlag()) {
2169-
composedSchema.example(subtypeModel.getExample());
2170-
}
2171-
composedSchema.setEnum(subtypeModel.getEnum());
2135+
composedSchema = ComposedSchema.from(subtypeModel);
21722136
} else {
21732137
composedSchema = (ComposedSchema) subtypeModel;
21742138
}

modules/swagger-core/src/test/java/io/swagger/v3/core/converting/ModelPropertyTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public void testReadOnlyProperty() {
103103
public void testRequiredProperty() {
104104
final Map<String, Schema> models = ModelConverters.getInstance().readAll(RequiredFields.class);
105105
Schema model = models.get("RequiredFields");
106+
assertFalse(model.getRequired().contains("optionalField"));
107+
assertFalse(model.getRequired().contains("primitiveTypeWithoutConstraint"));
108+
assertTrue(model.getRequired().contains("primitiveTypeWithConstraint"));
106109
assertTrue(model.getRequired().contains("required"));
107110
assertFalse(model.getRequired().contains("notRequired"));
108111
assertTrue(model.getRequired().contains("notRequiredWithAnnotation"));

modules/swagger-core/src/test/java/io/swagger/v3/core/oas/models/RequiredFields.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.swagger.v3.oas.annotations.media.Schema;
44

55
import javax.validation.constraints.NotNull;
6+
import java.util.Optional;
67

78
public class RequiredFields {
89
@Schema(description = "required", required = true)
@@ -11,10 +12,20 @@ public class RequiredFields {
1112
@Schema(description = "not required")
1213
public Long notRequired;
1314

15+
@Schema(description = "Optional field")
16+
public Optional<Long> optionalField;
17+
1418
@Schema(description = "not required with annotation")
1519
@NotNull
1620
public Long notRequiredWithAnnotation;
1721

22+
@Schema(description = "primitive type without constraint")
23+
public long primitiveTypeWithoutConstraint;
24+
25+
@Schema(description = "primitive type with constraint")
26+
@NotNull
27+
public long primitiveTypeWithConstraint;
28+
1829
@Schema(description = "mode auto", requiredMode = Schema.RequiredMode.AUTO)
1930
public Long modeAuto;
2031

modules/swagger-eclipse-transformer-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.swagger.core.v3</groupId>
66
<artifactId>swagger-project</artifactId>
7-
<version>2.2.38-SNAPSHOT</version>
7+
<version>2.2.39-SNAPSHOT</version>
88
<relativePath>../..</relativePath>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>

modules/swagger-gradle-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Alternatively provide as value a classpath with the following dependencies (repl
2626

2727
```
2828
plugins {
29-
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.2.37"
29+
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.2.38"
3030
}
3131
```
3232
### Gradle 1.x and 2.0
@@ -43,7 +43,7 @@ buildscript {
4343
}
4444
}
4545
dependencies {
46-
classpath "io.swagger.core.v3:swagger-gradle-plugin:2.2.37"
46+
classpath "io.swagger.core.v3:swagger-gradle-plugin:2.2.38"
4747
}
4848
}
4949
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=2.2.38-SNAPSHOT
1+
version=2.2.39-SNAPSHOT
22
jettyVersion=9.4.53.v20231009

0 commit comments

Comments
 (0)