stcarrez / swagger-ada

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

Boolean parameters not supported #14

Closed mgrojo closed 2 years ago

mgrojo commented 2 years ago

Hi Stephane,

Adding boolean parameters generates incorrect code for the skeleton. I was able to workaround this modifying the generated code to call this new procedure:

package body Swagger.Servers.Fix is

   procedure Get_Query_Parameter (Req   : in Request'Class;
                                  Name  : in String;
                                  Value : out Nullable_Boolean)  is
      V : constant String := Req.Get_Parameter (Name);
   begin
      Value.Is_Null := V'Length = 0;
      if Value.Is_Null then
         Value.Value := False;
      else
         Value.Value := Boolean'Value (V);
      end if;
   end Get_Query_Parameter;

end Swagger.Servers.Fix;

Let me know if you'd like a pull request to include it properly in your project.

stcarrez commented 2 years ago

If you submit a pull request, it is fine for me!

mgrojo commented 2 years ago

Done!

mgrojo commented 2 years ago

By the way, I had to do this in order to compile it, but don't know where it should be modified to automate the correct file generation:

mv src/server/swagger-servers-config.ads src/server/openapi-servers-config.ads