Skip to content

Commit dfec49c

Browse files
committed
Allow array using
1 parent 515bf22 commit dfec49c

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

moqu/core/src/test/java/io/quarkiverse/openapi/generator/OpenAPIMoquImporterTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package io.quarkiverse.openapi.generator;
22

3+
import io.quarkiverse.openapi.generator.marshall.ObjectMapperFactory;
34
import org.assertj.core.api.SoftAssertions;
45
import org.junit.jupiter.api.Assertions;
56
import org.junit.jupiter.api.DisplayName;
67
import org.junit.jupiter.api.Test;
78

9+
import java.util.List;
10+
import java.util.Map;
11+
812
class OpenAPIMoquImporterTest {
913

1014
private final MoquImporter sut = new OpenAPIMoquImporter();
@@ -156,4 +160,24 @@ void shouldGenerateAResponseFromRef() {
156160
});
157161
});
158162
}
163+
164+
@Test
165+
@DisplayName("Should generate a response from ref as array")
166+
void shouldGenerateAResponseFromRefAsArray() {
167+
String content = Testing.readContentFromFile("wiremock/response_from_ref_array.yml");
168+
Moqu moqu = sut.parse(content);
169+
SoftAssertions.assertSoftly(softly -> {
170+
softly.assertThat(moqu.getRequestResponsePairs()).isNotEmpty();
171+
softly.assertThat(moqu.getRequestResponsePairs()).hasSize(1);
172+
softly.assertThat(moqu.getRequestResponsePairs().get(0)).satisfies(requestResponsePair -> {
173+
Map map = ObjectMapperFactory.getInstance().readValue(
174+
requestResponsePair.response()
175+
.content(),
176+
Map.class
177+
);
178+
softly.assertThat((List) map.get("versions"))
179+
.hasSize(2);
180+
});
181+
});
182+
}
159183
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
openapi: 3.0.3
2+
servers:
3+
- url: http://localhost:8888
4+
info:
5+
version: 999-SNAPSHOT
6+
title: Method GET one path param
7+
paths:
8+
"/frameworks/{id}":
9+
get:
10+
parameters:
11+
- name: id
12+
in: path
13+
examples:
14+
quarkus:
15+
value: 1
16+
responses:
17+
200:
18+
content:
19+
"application/json":
20+
examples:
21+
quarkus:
22+
$ref: "#/components/schemas/Framework"
23+
description: Ok
24+
components:
25+
schemas:
26+
Framework:
27+
type: object
28+
properties:
29+
name:
30+
type: string
31+
example: "Quarkus"
32+
versions:
33+
type: array
34+
example: ["999-SNAPSHOT", "3.15.1"]

0 commit comments

Comments
 (0)