Skip to content

Commit 130f627

Browse files
committed
Allow using and with no
1 parent dfec49c commit 130f627

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,34 @@ void shouldGenerateAResponseFromRefAsArray() {
180180
});
181181
});
182182
}
183+
184+
@Test
185+
@DisplayName("Should generate a response from $ref and with no $ref")
186+
void shouldGenerateAResponseFromRefAndNoRef() {
187+
String content = Testing.readContentFromFile("wiremock/response_from_ref_and_noref.yml");
188+
Moqu moqu = sut.parse(content);
189+
SoftAssertions.assertSoftly(softly -> {
190+
softly.assertThat(moqu.getRequestResponsePairs()).isNotEmpty();
191+
softly.assertThat(moqu.getRequestResponsePairs()).hasSize(2);
192+
softly.assertThat(moqu.getRequestResponsePairs()).anySatisfy(requestResponsePair -> {
193+
Map map = ObjectMapperFactory.getInstance().readValue(
194+
requestResponsePair.response()
195+
.content(),
196+
Map.class
197+
);
198+
softly.assertThat((List) map.get("versions"))
199+
.hasSize(2);
200+
});
201+
202+
softly.assertThat(moqu.getRequestResponsePairs()).anySatisfy(requestResponsePair -> {
203+
Map map = ObjectMapperFactory.getInstance().readValue(
204+
requestResponsePair.response()
205+
.content(),
206+
Map.class
207+
);
208+
softly.assertThat((List) map.get("versions"))
209+
.hasSize(1);
210+
});
211+
});
212+
}
183213
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
vertx:
17+
value: 2
18+
responses:
19+
200:
20+
content:
21+
"application/json":
22+
examples:
23+
quarkus:
24+
$ref: "#/components/schemas/Framework"
25+
vertx:
26+
value: '{ "name": "Vert.x", "versions": ["999-SNAPSHOT"]}'
27+
description: Ok
28+
components:
29+
schemas:
30+
Framework:
31+
type: object
32+
properties:
33+
name:
34+
type: string
35+
example: "Quarkus"
36+
versions:
37+
type: array
38+
example: [ "999-SNAPSHOT", "3.15.1" ]

0 commit comments

Comments
 (0)