From 43f0e86923e8be80ce6cc48557e65b8d9da2a4a2 Mon Sep 17 00:00:00 2001 From: micheleISEP Date: Mon, 22 Jan 2018 09:40:34 +0000 Subject: [PATCH] Ada code generator corrected: "=>" instead of "->". Fixes #7450 (#7456) * Ada generator generates "=>" (correct syntax) instead of "->". Fixes #7450 * Updated the Ada petstore samples * Committing "VERSION" file and the rest of the petstore samples --- .../main/resources/Ada/client-body.mustache | 2 +- .../ada/src/samples-petstore-client.adb | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 samples/client/petstore/ada/src/samples-petstore-client.adb diff --git a/modules/swagger-codegen/src/main/resources/Ada/client-body.mustache b/modules/swagger-codegen/src/main/resources/Ada/client-body.mustache index 87531d7318..d4a3613bae 100644 --- a/modules/swagger-codegen/src/main/resources/Ada/client-body.mustache +++ b/modules/swagger-codegen/src/main/resources/Ada/client-body.mustache @@ -22,7 +22,7 @@ package body {{package}}.Clients is {{#hasProduces}} Client.Set_Accept (({{#produces}}{{#vendorExtensions.x-has-uniq-produces}}1 => {{/vendorExtensions.x-has-uniq-produces}}Swagger.Clients.{{adaMediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}));{{/hasProduces}}{{#hasBodyParam}} - Client.Initialize (Req, ({{#hasConsumes}}{{#consumes}}{{#vendorExtensions.x-has-uniq-consumes}}1 -> {{/vendorExtensions.x-has-uniq-consumes}}Swagger.Clients.{{adaMediaType}}{{#hasMore}}, + Client.Initialize (Req, ({{#hasConsumes}}{{#consumes}}{{#vendorExtensions.x-has-uniq-consumes}}1 => {{/vendorExtensions.x-has-uniq-consumes}}Swagger.Clients.{{adaMediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{/hasConsumes}}{{^hasConsumes}}1 => Swagger.Clients.APPLICATION_JSON{{/hasConsumes}}));{{#bodyParams}}{{#vendorExtensions.x-is-model-type}} {{package}}.Models.Serialize (Req.Stream, "", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{#isFile}} -- TODO: Serialize (Req.Stream, "{{basename}}", {{paramName}});{{/isFile}}{{^isFile}}{{^isLong}} diff --git a/samples/client/petstore/ada/src/samples-petstore-client.adb b/samples/client/petstore/ada/src/samples-petstore-client.adb new file mode 100644 index 0000000000..f8e5e53ff4 --- /dev/null +++ b/samples/client/petstore/ada/src/samples-petstore-client.adb @@ -0,0 +1,43 @@ +with Samples.Petstore.Clients; +with Samples.Petstore.Models; +with Swagger; +with Util.Http.Clients.Curl; +with Ada.Text_IO; +with Ada.Command_Line; +with Ada.Calendar.Formatting; +with Ada.Exceptions; +procedure Samples.Petstore.Client is + + use Ada.Text_IO; + + procedure Usage; + + Server : constant Swagger.UString := Swagger.To_UString ("http://localhost:8080/v2"); + Arg_Count : constant Natural := Ada.Command_Line.Argument_Count; + Arg : Positive := 1; + + procedure Usage is + begin + Put_Line ("Usage: Petstore {params}..."); + end Usage; + +begin + if Arg_Count <= 1 then + Usage; + return; + end if; + Util.Http.Clients.Curl.Register; + declare + Command : constant String := Ada.Command_Line.Argument (Arg); + Item : constant String := Ada.Command_Line.Argument (Arg + 1); + C : Samples.Petstore.Clients.Client_Type; + begin + C.Set_Server (Server); + Arg := Arg + 2; + + exception + when E : Constraint_Error => + Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E)); + + end; +end Samples.Petstore.Client;