Skip to main content
Solved

swagger.json API spec does not validate/match with returned data in Openapi generator client

  • September 22, 2024
  • 2 replies
  • 142 views

Hi,

I used the screen “Web Services Endpoints” then menu “… > Service Definition > Open API 2.0” to generate the swagger.json file.

This is for the Acumatica: "/entity/Default/23.200.001" collection

I then processed that through the openapi-generator to generate a java client:

java -jar openapi-generator-cli-7.8.0.jar generate -i [domain]entity/Default/23.200.001/swagger.json?company=[company] -g java --api-package [mypackage].finance.acumatica.openapi.client --model-package [mypackage].acumatica.openapi.client.model -o testoutput --skip-validate-spec

That generates the java client .java files.  These all compile to .class files without any errors.

So this all looks good so far.  This is industry standard for generating a client from swagger.json data.

 

 

However when I run the client I get an error.  The client makes a request to acumatica for data like:

                        VendorApi va = new VendorApi(apiClient);

                        List ids = new ArrayList();

                        ids.add("V00002");

                        

                        Vendor vendor = va.vendorGetByKeys(ids, null, null, null, null);

 

However the call to vendorGetByKeys fails with an error:

 

The field `_links` in the JSON string is not defined in the `Vendor` properties. JSON: {"id":"e82950d0-11f2-ee11-835e-02e72c89c05e","rowNumber":1,"note":{"value":""},"AccountRef":{},

…[a whole bunch more JSON of the Vendor record that I cut out for brevity]...

"_links":{"self":"/entity/Default/23.200.001/Vendor/e82950d0-11f2-ee11-835e-02e72c89c05e","files:put":"/entity/Default/23.200.001/files/PX.Objects.AP.VendorMaint/BAccount/e82950d0-11f2-ee11-835e-02e72c89c05e/{filename}"}}

 

Basically the “links” tag, at the very end of the Vendor record is not expected as per the swagger.json file.  However it is returned by the acumatica webservice end point.


So basically the API swagger.json specification says one format (no “links” data) and the actual returned JSON from acumatica is a different format (with the “links” data).

Is there a reason for this? 

How can this be resolved?

Please let me know.

Thanks

Alex.

Best answer by Dmitrii Naumov

@alexacumatica 

 

It’s fixed in 2024 R2 version and the OpenAPI version changed to 3

 

By the way, we do have client generated for Java here:

https://github.com/Acumatica/Java-based-REST-API/blob/main/Acumatica-RestApi-Default20_200_001/src/main/java/model/ACAInfoDetail.java

 (Only for 20.200.001 Default endpoint though)

View original
Did this topic help you find an answer to your question?

2 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 629 replies
  • Answer
  • September 26, 2024

@alexacumatica 

 

It’s fixed in 2024 R2 version and the OpenAPI version changed to 3

 

By the way, we do have client generated for Java here:

https://github.com/Acumatica/Java-based-REST-API/blob/main/Acumatica-RestApi-Default20_200_001/src/main/java/model/ACAInfoDetail.java

 (Only for 20.200.001 Default endpoint though)


  • Author
  • Freshman I
  • 1 reply
  • October 7, 2024

Thank you for the response.  My acumatica partner has installed a new instance of acumatica using the 2024R2 release:

 

I have downloaded and processed the swagger.json file from the instance:

https://[clientsubdomain].acumatica.com/entity/Default/24.200.001/swagger.json?company=[clientCompanyName]

This file does not contain any reference to the “_links” json object.  That is not looking good.

I updated my application using this new client library.

However, when a request is made to this endpoint using the API:

VendorApi va = new VendorApi(apiClient);



Vendor vendor = va.vendorGetByKeys(“V00002”, null, null, null, null);

 

Then the exact same error occurs as above.  Basically, the _links value is still part of the JSON returned from Acumatica web services.  However the json openapi swagger client is not including the “_links” attribute as part of the json specification.  Here is the links tag from the response:

"_links":{"self":"/entity/Default/24.200.001/Vendor/e82950d0-11f2-ee11-835e-02e72c89c05e","files:put":"/entity/Default/24.200.001/files/PX.Objects.AP.VendorMaint/BAccount/e82950d0-11f2-ee11-835e-02e72c89c05e/{filename}"}

You can see in the data that is coming back from acumatica end point that it is referencing the 24.200.001 release.  So this is a good indication that my endpoint request is valid.

Short story is that the upgrade to 24.200.001 does not seem to fix the web services mismatch between:

 (a) the Acumatica provided swagger JSON specification

 (b) the Acumatica data response from the end point.

 

Please let me know what is needed to fix this.

Thanks

Alex.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings