Skip to content

Commit d289677

Browse files
committed
[java][okhttp] Regenerate samples and port the invoker unit tests
Regenerated for the composed fromJson/toJson helpers and the anyType validation fix. Ports the 8 hand-maintained invoker tests from the okhttp-gson petstore sample (ApiClient, Client, Configuration, JSON, StringUtil, ApiKeyAuth, HttpBasicAuth, RetryingOAuth), adapted to this library: byte[] auth payloads, the Oltu-free RetryingOAuth is exercised against a local HttpServer instead of Mockito, JSONTest uses the composed-model fromJson/toJson helpers and the library's fail-fast discriminator messages, and equals() assertions avoid reflectionEquals (needs --add-opens on JDK 9+). Suite: 501 tests, 0 failures.
1 parent ec5c82c commit d289677

31 files changed

Lines changed: 2058 additions & 10 deletions

‎samples/client/others/java/okhttp-oneOf-array/src/main/java/org/openapitools/client/model/MyExampleGet200Response.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,5 +283,24 @@ public OneOf1 getOneOf1() throws ClassCastException {
283283

284284

285285

286+
/**
287+
* Create an instance of MyExampleGet200Response given an JSON string
288+
*
289+
* @param jsonString JSON string
290+
* @return An instance of MyExampleGet200Response
291+
* @throws IOException if the JSON string is invalid with respect to MyExampleGet200Response
292+
*/
293+
public static MyExampleGet200Response fromJson(String jsonString) throws IOException {
294+
return JSON.getGson().fromJson(jsonString, MyExampleGet200Response.class);
295+
}
296+
297+
/**
298+
* Convert an instance of MyExampleGet200Response to an JSON string
299+
*
300+
* @return JSON string
301+
*/
302+
public String toJson() {
303+
return JSON.getGson().toJson(this);
304+
}
286305
}
287306

‎samples/client/others/java/okhttp-oneOf/src/main/java/org/openapitools/client/model/MyExamplePostRequest.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,24 @@ public String getString() throws ClassCastException {
217217

218218

219219

220+
/**
221+
* Create an instance of MyExamplePostRequest given an JSON string
222+
*
223+
* @param jsonString JSON string
224+
* @return An instance of MyExamplePostRequest
225+
* @throws IOException if the JSON string is invalid with respect to MyExamplePostRequest
226+
*/
227+
public static MyExamplePostRequest fromJson(String jsonString) throws IOException {
228+
return JSON.getGson().fromJson(jsonString, MyExamplePostRequest.class);
229+
}
230+
231+
/**
232+
* Convert an instance of MyExamplePostRequest to an JSON string
233+
*
234+
* @return JSON string
235+
*/
236+
public String toJson() {
237+
return JSON.getGson().toJson(this);
238+
}
220239
}
221240

‎samples/client/others/java/okhttp-streaming/src/main/java/org/openapitools/client/model/SimpleOneOf.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,24 @@ public Integer getInteger() throws ClassCastException {
271271

272272

273273

274+
/**
275+
* Create an instance of SimpleOneOf given an JSON string
276+
*
277+
* @param jsonString JSON string
278+
* @return An instance of SimpleOneOf
279+
* @throws IOException if the JSON string is invalid with respect to SimpleOneOf
280+
*/
281+
public static SimpleOneOf fromJson(String jsonString) throws IOException {
282+
return JSON.getGson().fromJson(jsonString, SimpleOneOf.class);
283+
}
284+
285+
/**
286+
* Convert an instance of SimpleOneOf to an JSON string
287+
*
288+
* @return JSON string
289+
*/
290+
public String toJson() {
291+
return JSON.getGson().toJson(this);
292+
}
274293
}
275294

‎samples/client/petstore/java/okhttp-3.1/src/main/java/org/openapitools/client/model/OneOfStringOrInt.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,24 @@ public Integer getInteger() throws ClassCastException {
371371

372372

373373

374+
/**
375+
* Create an instance of OneOfStringOrInt given an JSON string
376+
*
377+
* @param jsonString JSON string
378+
* @return An instance of OneOfStringOrInt
379+
* @throws IOException if the JSON string is invalid with respect to OneOfStringOrInt
380+
*/
381+
public static OneOfStringOrInt fromJson(String jsonString) throws IOException {
382+
return JSON.getGson().fromJson(jsonString, OneOfStringOrInt.class);
383+
}
384+
385+
/**
386+
* Convert an instance of OneOfStringOrInt to an JSON string
387+
*
388+
* @return JSON string
389+
*/
390+
public String toJson() {
391+
return JSON.getGson().toJson(this);
392+
}
374393
}
375394

‎samples/client/petstore/java/okhttp-3.1/src/main/java/org/openapitools/client/model/RefRefToPathLevelParameterOneofRefToOneofParameter.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,24 @@ public Integer getInteger() throws ClassCastException {
371371

372372

373373

374+
/**
375+
* Create an instance of RefRefToPathLevelParameterOneofRefToOneofParameter given an JSON string
376+
*
377+
* @param jsonString JSON string
378+
* @return An instance of RefRefToPathLevelParameterOneofRefToOneofParameter
379+
* @throws IOException if the JSON string is invalid with respect to RefRefToPathLevelParameterOneofRefToOneofParameter
380+
*/
381+
public static RefRefToPathLevelParameterOneofRefToOneofParameter fromJson(String jsonString) throws IOException {
382+
return JSON.getGson().fromJson(jsonString, RefRefToPathLevelParameterOneofRefToOneofParameter.class);
383+
}
384+
385+
/**
386+
* Convert an instance of RefRefToPathLevelParameterOneofRefToOneofParameter to an JSON string
387+
*
388+
* @return JSON string
389+
*/
390+
public String toJson() {
391+
return JSON.getGson().toJson(this);
392+
}
374393
}
375394

‎samples/client/petstore/java/okhttp-3.1/src/main/java/org/openapitools/client/model/RefToRefParameterAnyofRefToAnyofParameter.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,24 @@ public List<String> getListString() throws ClassCastException {
383383

384384

385385

386+
/**
387+
* Create an instance of RefToRefParameterAnyofRefToAnyofParameter given an JSON string
388+
*
389+
* @param jsonString JSON string
390+
* @return An instance of RefToRefParameterAnyofRefToAnyofParameter
391+
* @throws IOException if the JSON string is invalid with respect to RefToRefParameterAnyofRefToAnyofParameter
392+
*/
393+
public static RefToRefParameterAnyofRefToAnyofParameter fromJson(String jsonString) throws IOException {
394+
return JSON.getGson().fromJson(jsonString, RefToRefParameterAnyofRefToAnyofParameter.class);
395+
}
396+
397+
/**
398+
* Convert an instance of RefToRefParameterAnyofRefToAnyofParameter to an JSON string
399+
*
400+
* @return JSON string
401+
*/
402+
public String toJson() {
403+
return JSON.getGson().toJson(this);
404+
}
386405
}
387406

‎samples/client/petstore/java/okhttp-3.1/src/main/java/org/openapitools/client/model/SelfReferenceOneOf.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,24 @@ public Boolean getBoolean() throws ClassCastException {
371371

372372

373373

374+
/**
375+
* Create an instance of SelfReferenceOneOf given an JSON string
376+
*
377+
* @param jsonString JSON string
378+
* @return An instance of SelfReferenceOneOf
379+
* @throws IOException if the JSON string is invalid with respect to SelfReferenceOneOf
380+
*/
381+
public static SelfReferenceOneOf fromJson(String jsonString) throws IOException {
382+
return JSON.getGson().fromJson(jsonString, SelfReferenceOneOf.class);
383+
}
384+
385+
/**
386+
* Convert an instance of SelfReferenceOneOf to an JSON string
387+
*
388+
* @return JSON string
389+
*/
390+
public String toJson() {
391+
return JSON.getGson().toJson(this);
392+
}
374393
}
375394

‎samples/client/petstore/java/okhttp/src/main/java/org/openapitools/client/model/AllOfModelArrayAnyOfAllOfAttributesC.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,5 +379,24 @@ public Order getOrder() throws ClassCastException {
379379

380380

381381

382+
/**
383+
* Create an instance of AllOfModelArrayAnyOfAllOfAttributesC given an JSON string
384+
*
385+
* @param jsonString JSON string
386+
* @return An instance of AllOfModelArrayAnyOfAllOfAttributesC
387+
* @throws IOException if the JSON string is invalid with respect to AllOfModelArrayAnyOfAllOfAttributesC
388+
*/
389+
public static AllOfModelArrayAnyOfAllOfAttributesC fromJson(String jsonString) throws IOException {
390+
return JSON.getGson().fromJson(jsonString, AllOfModelArrayAnyOfAllOfAttributesC.class);
391+
}
392+
393+
/**
394+
* Convert an instance of AllOfModelArrayAnyOfAllOfAttributesC to an JSON string
395+
*
396+
* @return JSON string
397+
*/
398+
public String toJson() {
399+
return JSON.getGson().toJson(this);
400+
}
382401
}
383402

‎samples/client/petstore/java/okhttp/src/main/java/org/openapitools/client/model/ArrayOneOf.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,5 +385,24 @@ public List<String> getListString() throws ClassCastException {
385385

386386

387387

388+
/**
389+
* Create an instance of ArrayOneOf given an JSON string
390+
*
391+
* @param jsonString JSON string
392+
* @return An instance of ArrayOneOf
393+
* @throws IOException if the JSON string is invalid with respect to ArrayOneOf
394+
*/
395+
public static ArrayOneOf fromJson(String jsonString) throws IOException {
396+
return JSON.getGson().fromJson(jsonString, ArrayOneOf.class);
397+
}
398+
399+
/**
400+
* Convert an instance of ArrayOneOf to an JSON string
401+
*
402+
* @return JSON string
403+
*/
404+
public String toJson() {
405+
return JSON.getGson().toJson(this);
406+
}
388407
}
389408

‎samples/client/petstore/java/okhttp/src/main/java/org/openapitools/client/model/FakeOneOfWIthSameErasureGet200Response.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,5 +346,24 @@ public List<Integer> getListInteger() throws ClassCastException {
346346

347347

348348

349+
/**
350+
* Create an instance of FakeOneOfWIthSameErasureGet200Response given an JSON string
351+
*
352+
* @param jsonString JSON string
353+
* @return An instance of FakeOneOfWIthSameErasureGet200Response
354+
* @throws IOException if the JSON string is invalid with respect to FakeOneOfWIthSameErasureGet200Response
355+
*/
356+
public static FakeOneOfWIthSameErasureGet200Response fromJson(String jsonString) throws IOException {
357+
return JSON.getGson().fromJson(jsonString, FakeOneOfWIthSameErasureGet200Response.class);
358+
}
359+
360+
/**
361+
* Convert an instance of FakeOneOfWIthSameErasureGet200Response to an JSON string
362+
*
363+
* @return JSON string
364+
*/
365+
public String toJson() {
366+
return JSON.getGson().toJson(this);
367+
}
349368
}
350369

0 commit comments

Comments
 (0)