Test Data Manager

Swagger Java Client throws JSON exception

  • 1.  Swagger Java Client throws JSON exception

    Posted 10-18-2019 11:22 AM

    Hello, 


    We have generated an Swagger Java Client. using the Swagger UI JSON files.

    Example shown below

    java -jar swagger-codegen-cli-2.4.8.jar generate -i "swagger.json" -l java -o CATDMTestManager1 -apiPackage=CATDMAPI

    Through this generated Client we have managed to successfully login and get an authorization token.

    However when we make subsequent calls we are getting some exceptions.  This is where we need help with.


    Case 1 - Issue with De-serialisation an offset date.

    =====

    PiiData response = api.getAJobsPiiDataForOneTableUsingGET1(authorization, projectId, versionId, table, false);

    Result


    xception in thread "main" org.threeten.bp.format.DateTimeParseException: Text '1568825756733' could not be parsed at index 0

        at org.threeten.bp.format.DateTimeFormatter.parseToBuilder(DateTimeFormatter.java:1587)

        at org.threeten.bp.format.DateTimeFormatter.parse(DateTimeFormatter.java:1491)

        at org.threeten.bp.OffsetDateTime.parse(OffsetDateTime.java:359)

        at io.swagger.client.JSON$OffsetDateTimeTypeAdapter.read(JSON.java:219)

        at io.swagger.client.JSON$OffsetDateTimeTypeAdapter.read(JSON.java:182)


    Case 2 - Issue with Array De-Serialization of size 1.

    =======

    List<PiiDataColumn> PiiDataColumns =api.getAJobsPiiDataForOneTableAndColumnsUsingGET1(authorization, projectId, versionId, table, null, 10000, false, false);


    Result

    Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

        at com.google.gson.Gson.fromJson(Gson.java:939)

        at com.google.gson.Gson.fromJson(Gson.java:892)

        at com.google.gson.Gson.fromJson(Gson.java:841)

    looking forward to getting solution for these.



    thanks,

    Jaimini