Skip to content

Commit 283a170

Browse files
committed
test: Verify x-permissions flows through fixture parse
1 parent dba432f commit 283a170

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/test/java/com/retailsvc/http/spec/ExtensionsTest.java

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

33
import static org.assertj.core.api.Assertions.assertThat;
44

5+
import com.google.gson.Gson;
56
import java.util.List;
67
import java.util.Map;
78
import org.junit.jupiter.api.Test;
@@ -127,6 +128,22 @@ void stringSchemaExtensionsExposeXKeys() {
127128
.containsEntry("x-format-hint", "slug");
128129
}
129130

131+
@Test
132+
@SuppressWarnings("unchecked")
133+
void fixtureOperationExtensionsAreReadable() throws Exception {
134+
Gson gson = new Gson();
135+
String text =
136+
new String(ExtensionsTest.class.getResourceAsStream("/openapi.json").readAllBytes());
137+
Map<String, Object> raw = (Map<String, Object>) gson.fromJson(text, Map.class);
138+
Spec spec = Spec.from(raw);
139+
Operation op =
140+
spec.operations().stream()
141+
.filter(o -> "post-data".equals(o.operationId()))
142+
.findFirst()
143+
.orElseThrow();
144+
assertThat(op.extensions()).containsEntry("x-permissions", List.of("pro.promotion.create"));
145+
}
146+
130147
@Test
131148
void oneOfSchemaExtensionsExposeXKeys() {
132149
Map<String, Object> raw =

src/test/resources/openapi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
},
4242
"post": {
4343
"operationId": "post-data",
44+
"x-permissions": ["pro.promotion.create"],
4445
"requestBody": {
4546
"content": {
4647
"application/json": {

src/test/resources/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ paths:
2828

2929
post:
3030
operationId: post-data
31+
x-permissions:
32+
- pro.promotion.create
3133
requestBody:
3234
content:
3335
application/json:

0 commit comments

Comments
 (0)