Skip to content

Commit fef4cf6

Browse files
committed
v32: new property
1 parent a503697 commit fef4cf6

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

openapi-parser/src/main/java/io/openapiparser/Keywords.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface Keywords {
2626
String CONTENT_TYPE = "contentType";
2727
String DATA_VALUE = "dataValue";
2828
String DEFAULT = "default";
29+
String DEFAULT_MAPPING = "defaultMapping";
2930
String DELETE = "delete";
3031
String DEPENDENT_REQUIRED = "dependentRequired";
3132
String DEPRECATED = "deprecated";

openapi-parser/src/main/java/io/openapiparser/model/v32/Discriminator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
import java.util.Map;
1515

16-
import static io.openapiparser.Keywords.MAPPING;
17-
import static io.openapiparser.Keywords.PROPERTY_NAME;
16+
import static io.openapiparser.Keywords.*;
1817

1918
/**
2019
* the <em>Discriminator</em> object.
@@ -37,6 +36,10 @@ public Map<String, String> getMapping () {
3736
return getMapStringsOrEmpty (MAPPING);
3837
}
3938

39+
public String getDefaultMapping () {
40+
return getStringOrNull (DEFAULT_MAPPING);
41+
}
42+
4043
@Override
4144
public Map<String, @Nullable Object> getExtensions () {
4245
return super.getExtensions ();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2025 https://github.com/openapi-processor/openapi-parser
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiparser.model.v32
7+
8+
import io.kotest.core.spec.style.StringSpec
9+
import io.kotest.matchers.nulls.shouldBeNull
10+
import io.kotest.matchers.shouldBe
11+
12+
/**
13+
* @see [io.openapiparser.model.v31.DiscriminatorSpec], [io.openapiparser.model.v3x.DiscriminatorSpec]
14+
*/
15+
class DiscriminatorSpec: StringSpec ({
16+
17+
"gets default mapping" {
18+
discriminator("defaultMapping: mapping").defaultMapping.shouldBe("mapping")
19+
}
20+
21+
"gets default mapping is null if missing" {
22+
discriminator().defaultMapping.shouldBeNull()
23+
}
24+
})

0 commit comments

Comments
 (0)