stcarrez / swagger-ada

Ada support for OpenAPI code generator
Apache License 2.0
27 stars 3 forks source link

Swagger object --> set_Value give null result when trying get_value #4

Closed S0me6uy closed 3 years ago

S0me6uy commented 3 years ago

Hello,

I'm sure about 99% i misunderstood something, but i found no way to solve my issue.

When i create a swagger object (AKA message in following image), and then i set a value in, as in the image, result of line "extraction is "null", so i suppose my set_value has an error, but i don't find where. Is someone knowing what's wrong with it ?

test

Thanks a lot in advance.

stcarrez commented 3 years ago

Yes, there is missing a Utils.Beans.Objects.Maps.Create to build the initial map.

with Util.Beans.Objects.Maps;
...
    Message : Swagger.Object := Util.Beans.Objects.Maps.Create;
begin
    Set_Value (Message, "test", Util.Beans.Objects.To_Object (test));

By default when you create an instance of Swagger.Object, that instance is null which means it cannot hold anything. Whatever you do, you must assign a value to that object: it can be a string, an integer, a date, an array or a map.

If you assign a simple type such as string, integer, date the Set_Value will do nothing. It's the same if the value is null.

S0me6uy commented 3 years ago

Thank you, it's working now, but just in this case. When i try to send request with this Swagger.object, request body (intercepted with wireshark) looks like this :

BOaci68ouM

and i was waiting about seeing something closer to that : BxiGHuuc2O

method in my src/client is following :

procedure Receive_Event_Using_POST
      (Client : in out Client_Type;
       Event : in Swagger.Object;
       Result : out Swagger.UString) is
      URI   : Swagger.Clients.URI_Type;
      Req   : Swagger.Clients.Request_Type;
      Reply : Swagger.Value_Type;
begin

      Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
      Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
      Req.Stream.Write_Entity ("event", Event);

      URI.Set_Path ("/eventListener/v1");
      Client.Call (Swagger.Clients.POST, URI, Req, Reply);
      Swagger.Streams.Deserialize (Reply, "", Result);
   end Receive_Event_Using_POST

Moreover in this code, Req.Stream.Write_Entity is pointing to the right method i guess as the screen capture below shows it : vmware_dLSePVwp3H

I've no compilation error or anything else, just erratic comportment in using that. i think once again i missed something but i have no idea what without error message or anything else.

S0me6uy commented 3 years ago

Hello,

I'm still blocked : do you have any idea to solve my problem ?

Thank you in advance for help.

stcarrez commented 3 years ago

Yes, I've made a correction in the Ada Utility Library. It didn't serialize the map objects. I've not yet had time to verify the integration...

S0me6uy commented 3 years ago

Ok. When do you plan to make correction on github ? (just for information)

stcarrez commented 3 years ago

The Travis-ci.org was broken and I had to switch to Travis-ci.com. I've triggered a build on docker so that the image should be ok. Yes, this should be ok now.

S0me6uy commented 3 years ago

Sorry, i've been busy since 3 weeks. Which image are you talking about and how could it help me to solve this bug ? i updated my ada-utils package, but i'm still getting same error in request than at the beginning (only type of data is transmitted).

S0me6uy commented 3 years ago

Sorry, it does work but there is still a bug I think: As the body of the object in the client request, there is an unintended comma I think. Did I do something wrong ?

Bug : xkiFWK1Ajl

vmware_lcAiQzJpL0 vmware_Odvn1uXN20

S0me6uy commented 3 years ago

Hello,

i see you have no activities since 12 of july, so i assumed you're in holidays. It's just to remind myself to you in case you forgot me ;-)

stcarrez commented 3 years ago

Sorry for the delay, I have a lot of work and I can update these projects on my free time.

I've investigated the problem and found the issue on my side. The root cause is in the Ada Utility Library.

I've fixed your issue and I also took the opportunity to integrate the latest version of the OpenAPI generator.

I've made a new release of all my projects so that everything should be available.

S0me6uy commented 3 years ago

Great!

I'll test it tomorrow!

Today in fact X)