File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
java/io/quarkiverse/openapi/generator Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 11package io .quarkiverse .openapi .generator ;
22
3+ import io .quarkiverse .openapi .generator .marshall .ObjectMapperFactory ;
34import org .assertj .core .api .SoftAssertions ;
45import org .junit .jupiter .api .Assertions ;
56import org .junit .jupiter .api .DisplayName ;
67import org .junit .jupiter .api .Test ;
78
9+ import java .util .List ;
10+ import java .util .Map ;
11+
812class 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}
Original file line number Diff line number Diff line change 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"]
You can’t perform that action at this time.
0 commit comments