Skip to content

Commit fea669c

Browse files
committed
overlay: overlay object (#120)
1 parent 9110b48 commit fea669c

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public interface Keywords {
110110

111111
Set<String> OPERATIONS = Set.of(DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE);
112112

113+
// overlay
114+
String OVERLAY = "overlay";
115+
113116
static Collection<String> getProperties(Collection<Keyword> keywords) {
114117
return keywords
115118
.stream ()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2024 https://github.com/openapi-processor/openapi-parser
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiparser.model.ov10;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* the <em>Specification Extensions</em> object.
12+
*
13+
* <p>See specification:
14+
* <a href="https://spec.openapis.org/overlay/v1.0.0.html#specification-extensions">
15+
* 4.6 Specification Extensions
16+
* </a>
17+
*/
18+
public interface Extensions {
19+
20+
/**
21+
* map of all extension properties.
22+
*
23+
* @return map of extension properties
24+
*/
25+
Map<String, Object> getExtensions ();
26+
27+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2024 https://github.com/openapi-processor/openapi-parser
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiparser.model.ov10;
7+
8+
import io.openapiparser.Context;
9+
import io.openapiparser.Properties;
10+
import io.openapiparser.support.Required;
11+
import io.openapiprocessor.jsonschema.schema.Bucket;
12+
13+
import java.util.Map;
14+
15+
import static io.openapiparser.Keywords.OVERLAY;
16+
17+
/**
18+
* the <em>Overlay</em> object.
19+
*
20+
* <p>See specification:
21+
* <a href="https://spec.openapis.org/overlay/v1.0.0.html#overlay-object">4.4.1 Overlay Object</a>
22+
*/
23+
public class Overlay extends Properties implements Extensions {
24+
25+
public Overlay (Context context, Bucket bucket) {
26+
super (context, bucket);
27+
}
28+
29+
@Required
30+
public String getOverlay () {
31+
return getStringOrThrow (OVERLAY);
32+
}
33+
34+
@Override
35+
public Map<String, Object> getExtensions() {
36+
return super.getExtensions ();
37+
}
38+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2024 https://github.com/openapi-processor/openapi-parser
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiparser.model.ov10
7+
8+
import io.kotest.assertions.throwables.shouldThrow
9+
import io.kotest.core.spec.style.StringSpec
10+
import io.kotest.matchers.shouldBe
11+
import io.openapiparser.model.v30.overlay
12+
import io.openapiprocessor.jsonschema.converter.NoValueException
13+
14+
class OverlaySpec: StringSpec({
15+
16+
"get overlay version" {
17+
overlay("overlay: 1.0.0").overlay shouldBe "1.0.0"
18+
}
19+
20+
"get overlay version throws if it is missing" {
21+
shouldThrow<NoValueException> { overlay().overlay }
22+
}
23+
})

openapi-parser/src/test/kotlin/io/openapiparser/model/v30/Builder.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.openapiparser.model.v30
77

8+
import io.openapiparser.model.ov10.Overlay
89
import io.openapiparser.support.buildObject
910

1011
fun callback(content: String = "{}"): Callback {
@@ -98,3 +99,7 @@ fun serverVariable(content: String = "{}"): ServerVariable {
9899
fun xml(content: String = "{}"): Xml {
99100
return buildObject(Xml::class.java, content)
100101
}
102+
103+
fun overlay(content: String = "{}"): Overlay {
104+
return buildObject(Overlay::class.java, content)
105+
}

0 commit comments

Comments
 (0)