diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java index 05e732b23f9..50f2db60053 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java @@ -26,6 +26,7 @@ import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; +import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; import org.slf4j.Logger; @@ -163,7 +164,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg addOption(CodegenConstants.PROJECT_NAME, "GNAT project name", this.projectName); - modelNameSuffix = "_Type"; + modelNameSuffix = "Type"; embeddedTemplateDir = templateDir = "Ada"; languageSpecificPrimitives = new HashSet( @@ -242,11 +243,37 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg * @return capitalized model name */ public String toModelName(final String name) { - String result = super.toModelName(name); - if (result.matches("^\\d.*") || result.startsWith("_")) { - result = "Model_" + result; + String result = camelize(sanitizeName(name)); + + if (!StringUtils.isEmpty(modelNamePrefix)) { + result = modelNamePrefix + "_" + result; } - return result.replaceAll("[\\.-]", "_").replaceAll("__+", "_"); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(name)) { + String modelName = "Model_" + result; + LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName); + return modelName; + } + + // model name starts with number + if (result.matches("^\\d.*")) { + String modelName = "Model_" + result; // e.g. 200Response => Model_200Response (after camelize) + LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName); + return modelName; + } + + if (languageSpecificPrimitives.contains(result)) { + String modelName = "Model_" + result; + LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName); + return modelName; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + result = result + "_" + modelNameSuffix; + } + + return result; } @Override @@ -517,7 +544,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg if (v instanceof CodegenModel) { CodegenModel m = (CodegenModel) v; List d = new ArrayList(); - for (CodegenProperty p : m.allVars) { + for (CodegenProperty p : m.vars) { boolean isModel = false; CodegenProperty item = p; if (p.isContainer) { @@ -531,9 +558,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg isModel = true; } p.vendorExtensions.put("x-is-model-type", isModel); + Boolean required = p.getRequired(); // Convert optional members to use the Nullable_ type. - if (!p.required && nullableTypeMapping.containsKey(p.dataType)) { + if (!Boolean.TRUE.equals(required) && nullableTypeMapping.containsKey(p.dataType)) { p.dataType = nullableTypeMapping.get(p.dataType); } } diff --git a/modules/openapi-generator/src/main/resources/Ada/gnat-project.mustache b/modules/openapi-generator/src/main/resources/Ada/gnat-project.mustache index c1fa58eebea..1f8ded35698 100644 --- a/modules/openapi-generator/src/main/resources/Ada/gnat-project.mustache +++ b/modules/openapi-generator/src/main/resources/Ada/gnat-project.mustache @@ -6,11 +6,12 @@ -- -- NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). with "config"; -with "util"; -with "util_http"; +with "utilada_sys"; +with "utilada_xml"; +with "utilada_http"; with "security"; with "swagger";{{#isServer}} -with "servlet"; +with "servletada"; with "swagger_server";{{/isServer}} project {{{projectName}}} is diff --git a/modules/openapi-generator/src/main/resources/Ada/server.mustache b/modules/openapi-generator/src/main/resources/Ada/server.mustache index 08aba9f071a..f0a0fd00885 100644 --- a/modules/openapi-generator/src/main/resources/Ada/server.mustache +++ b/modules/openapi-generator/src/main/resources/Ada/server.mustache @@ -2,17 +2,22 @@ with Ada.IO_Exceptions; with AWS.Config.Set; with Swagger.Servers.AWS; with Swagger.Servers.Applications; +with Util.Strings; with Util.Log.Loggers; with Util.Properties; +with Util.Properties.Basic; with {{package}}.Servers; procedure {{package}}.Server is procedure Configure (Config : in out AWS.Config.Object); + use Util.Properties.Basic; + CONFIG_PATH : constant String := "{{packageConfig}}.properties"; + Port : Natural := 8080; procedure Configure (Config : in out AWS.Config.Object) is begin - AWS.Config.Set.Server_Port (Config, 8080); + AWS.Config.Set.Server_Port (Config, Port); AWS.Config.Set.Max_Connection (Config, 8); AWS.Config.Set.Accept_Queue_Size (Config, 512); end Configure; @@ -25,13 +30,15 @@ begin Props.Load_Properties (CONFIG_PATH); Util.Log.Loggers.Initialize (Props); + Port := Integer_Property.Get (Props, "swagger.port", Port); App.Configure (Props); {{package}}.Servers.Server_Impl.Register (App); WS.Configure (Configure'Access); WS.Register_Application ("{{basePathWithoutHost}}", App'Unchecked_Access); App.Dump_Routes (Util.Log.INFO_LEVEL); - Log.Info ("Connect you browser to: http://localhost:8080{{basePathWithoutHost}}/ui/index.html"); + Log.Info ("Connect you browser to: http://localhost:{0}{{basePathWithoutHost}}/ui/index.html", + Util.Strings.Image (Port)); WS.Start; diff --git a/samples/client/petstore/ada/.openapi-generator/VERSION b/samples/client/petstore/ada/.openapi-generator/VERSION index afa63656064..58592f031f6 100644 --- a/samples/client/petstore/ada/.openapi-generator/VERSION +++ b/samples/client/petstore/ada/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/ada/petstore.gpr b/samples/client/petstore/ada/petstore.gpr index 4c8ce69b930..e4036b9bfa4 100644 --- a/samples/client/petstore/ada/petstore.gpr +++ b/samples/client/petstore/ada/petstore.gpr @@ -6,8 +6,9 @@ -- -- NOTE: Auto generated by the swagger code generator program. with "config"; -with "util"; -with "util_http"; +with "utilada_sys"; +with "utilada_xml"; +with "utilada_http"; with "security"; with "swagger"; project Petstore is diff --git a/samples/client/petstore/ada/src/client/samples-petstore-clients.adb b/samples/client/petstore/ada/src/client/samples-petstore-clients.adb index e479690cf44..1920cbf1fe4 100644 --- a/samples/client/petstore/ada/src/client/samples-petstore-clients.adb +++ b/samples/client/petstore/ada/src/client/samples-petstore-clients.adb @@ -1,10 +1,10 @@ -- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- --- OpenAPI spec version: 1.0.0 +-- The version of the OpenAPI document: 1.0.0 -- -- --- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT. +-- NOTE: This package is auto generated by OpenAPI-Generator 4.2.3-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. @@ -14,7 +14,7 @@ package body Samples.Petstore.Clients is -- Add a new pet to the store procedure Add_Pet (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.PetType) is + P_Body : in Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin @@ -46,7 +46,7 @@ package body Samples.Petstore.Clients is procedure Find_Pets_By_Status (Client : in out Client_Type; Status : in Swagger.UString_Vectors.Vector; - Result : out Samples.Petstore.Models.PetType_Vectors.Vector) is + Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin @@ -64,7 +64,7 @@ package body Samples.Petstore.Clients is procedure Find_Pets_By_Tags (Client : in out Client_Type; Tags : in Swagger.UString_Vectors.Vector; - Result : out Samples.Petstore.Models.PetType_Vectors.Vector) is + Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin @@ -82,7 +82,7 @@ package body Samples.Petstore.Clients is procedure Get_Pet_By_Id (Client : in out Client_Type; Pet_Id : in Swagger.Long; - Result : out Samples.Petstore.Models.PetType) is + Result : out Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin @@ -98,7 +98,7 @@ package body Samples.Petstore.Clients is -- Update an existing pet procedure Update_Pet (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.PetType) is + P_Body : in Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin @@ -136,7 +136,7 @@ package body Samples.Petstore.Clients is Pet_Id : in Swagger.Long; Additional_Metadata : in Swagger.Nullable_UString; File : in Swagger.File_Part_Type; - Result : out Samples.Petstore.Models.ApiResponseType) is + Result : out Samples.Petstore.Models.ApiResponse_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; @@ -186,7 +186,7 @@ package body Samples.Petstore.Clients is procedure Get_Order_By_Id (Client : in out Client_Type; Order_Id : in Swagger.Long; - Result : out Samples.Petstore.Models.OrderType) is + Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin @@ -202,8 +202,8 @@ package body Samples.Petstore.Clients is -- Place an order for a pet procedure Place_Order (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.OrderType; - Result : out Samples.Petstore.Models.OrderType) is + P_Body : in Samples.Petstore.Models.Order_Type; + Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; @@ -222,7 +222,7 @@ package body Samples.Petstore.Clients is -- This can only be done by the logged in user. procedure Create_User (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType) is + P_Body : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin @@ -237,7 +237,7 @@ package body Samples.Petstore.Clients is -- Creates list of users with given input array procedure Create_Users_With_Array_Input (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector) is + P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin @@ -252,7 +252,7 @@ package body Samples.Petstore.Clients is -- Creates list of users with given input array procedure Create_Users_With_List_Input (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector) is + P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin @@ -282,7 +282,7 @@ package body Samples.Petstore.Clients is procedure Get_User_By_Name (Client : in out Client_Type; Username : in Swagger.UString; - Result : out Samples.Petstore.Models.UserType) is + Result : out Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin @@ -330,7 +330,7 @@ package body Samples.Petstore.Clients is procedure Update_User (Client : in out Client_Type; Username : in Swagger.UString; - P_Body : in Samples.Petstore.Models.UserType) is + P_Body : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin diff --git a/samples/client/petstore/ada/src/client/samples-petstore-clients.ads b/samples/client/petstore/ada/src/client/samples-petstore-clients.ads index 581760b2404..adc6a3c692a 100644 --- a/samples/client/petstore/ada/src/client/samples-petstore-clients.ads +++ b/samples/client/petstore/ada/src/client/samples-petstore-clients.ads @@ -1,10 +1,10 @@ -- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- --- OpenAPI spec version: 1.0.0 +-- The version of the OpenAPI document: 1.0.0 -- -- --- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT. +-- NOTE: This package is auto generated by OpenAPI-Generator 4.2.3-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. @@ -17,7 +17,7 @@ package Samples.Petstore.Clients is -- Add a new pet to the store procedure Add_Pet (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.PetType); + P_Body : in Samples.Petstore.Models.Pet_Type); -- Deletes a pet procedure Delete_Pet @@ -30,26 +30,26 @@ package Samples.Petstore.Clients is procedure Find_Pets_By_Status (Client : in out Client_Type; Status : in Swagger.UString_Vectors.Vector; - Result : out Samples.Petstore.Models.PetType_Vectors.Vector); + Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector); -- Finds Pets by tags -- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. procedure Find_Pets_By_Tags (Client : in out Client_Type; Tags : in Swagger.UString_Vectors.Vector; - Result : out Samples.Petstore.Models.PetType_Vectors.Vector); + Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector); -- Find pet by ID -- Returns a single pet procedure Get_Pet_By_Id (Client : in out Client_Type; Pet_Id : in Swagger.Long; - Result : out Samples.Petstore.Models.PetType); + Result : out Samples.Petstore.Models.Pet_Type); -- Update an existing pet procedure Update_Pet (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.PetType); + P_Body : in Samples.Petstore.Models.Pet_Type); -- Updates a pet in the store with form data procedure Update_Pet_With_Form @@ -64,7 +64,7 @@ package Samples.Petstore.Clients is Pet_Id : in Swagger.Long; Additional_Metadata : in Swagger.Nullable_UString; File : in Swagger.File_Part_Type; - Result : out Samples.Petstore.Models.ApiResponseType); + Result : out Samples.Petstore.Models.ApiResponse_Type); -- Delete purchase order by ID -- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -83,29 +83,29 @@ package Samples.Petstore.Clients is procedure Get_Order_By_Id (Client : in out Client_Type; Order_Id : in Swagger.Long; - Result : out Samples.Petstore.Models.OrderType); + Result : out Samples.Petstore.Models.Order_Type); -- Place an order for a pet procedure Place_Order (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.OrderType; - Result : out Samples.Petstore.Models.OrderType); + P_Body : in Samples.Petstore.Models.Order_Type; + Result : out Samples.Petstore.Models.Order_Type); -- Create user -- This can only be done by the logged in user. procedure Create_User (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType); + P_Body : in Samples.Petstore.Models.User_Type); -- Creates list of users with given input array procedure Create_Users_With_Array_Input (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector); + P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector); -- Creates list of users with given input array procedure Create_Users_With_List_Input (Client : in out Client_Type; - P_Body : in Samples.Petstore.Models.UserType_Vectors.Vector); + P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector); -- Delete user -- This can only be done by the logged in user. @@ -117,7 +117,7 @@ package Samples.Petstore.Clients is procedure Get_User_By_Name (Client : in out Client_Type; Username : in Swagger.UString; - Result : out Samples.Petstore.Models.UserType); + Result : out Samples.Petstore.Models.User_Type); -- Logs user into the system procedure Login_User @@ -135,6 +135,6 @@ package Samples.Petstore.Clients is procedure Update_User (Client : in out Client_Type; Username : in Swagger.UString; - P_Body : in Samples.Petstore.Models.UserType); + P_Body : in Samples.Petstore.Models.User_Type); end Samples.Petstore.Clients; diff --git a/samples/client/petstore/ada/src/model/samples-petstore-models.adb b/samples/client/petstore/ada/src/model/samples-petstore-models.adb index d03b9401c37..db3f9463478 100644 --- a/samples/client/petstore/ada/src/model/samples-petstore-models.adb +++ b/samples/client/petstore/ada/src/model/samples-petstore-models.adb @@ -1,10 +1,10 @@ -- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- --- OpenAPI spec version: 1.0.0 +-- The version of the OpenAPI document: 1.0.0 -- -- --- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT. +-- NOTE: This package is auto generated by OpenAPI-Generator 4.2.3-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. @@ -17,7 +17,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in ApiResponseType) is + Value : in ApiResponse_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("code", Value.Code); @@ -28,7 +28,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in ApiResponseType_Vectors.Vector) is + Value : in ApiResponse_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -39,7 +39,7 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out ApiResponseType) is + Value : out ApiResponse_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); @@ -50,9 +50,9 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out ApiResponseType_Vectors.Vector) is + Value : out ApiResponse_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : ApiResponseType; + Item : ApiResponse_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); @@ -67,7 +67,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in TagType) is + Value : in Tag_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); @@ -77,7 +77,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in TagType_Vectors.Vector) is + Value : in Tag_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -88,7 +88,7 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out TagType) is + Value : out Tag_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); @@ -98,9 +98,9 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out TagType_Vectors.Vector) is + Value : out Tag_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : TagType; + Item : Tag_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); @@ -115,7 +115,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in CategoryType) is + Value : in Category_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); @@ -125,7 +125,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in CategoryType_Vectors.Vector) is + Value : in Category_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -136,7 +136,7 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out CategoryType) is + Value : out Category_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); @@ -146,9 +146,9 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out CategoryType_Vectors.Vector) is + Value : out Category_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : CategoryType; + Item : Category_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); @@ -163,7 +163,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in PetType) is + Value : in Pet_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); @@ -177,7 +177,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in PetType_Vectors.Vector) is + Value : in Pet_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -188,23 +188,23 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out PetType) is + Value : out Pet_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); - Swagger.Streams.Deserialize (Object, "category", Value.Category); + Deserialize (Object, "category", Value.Category); Swagger.Streams.Deserialize (Object, "name", Value.Name); Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls); - Swagger.Streams.Deserialize (Object, "tags", Value.Tags); + Deserialize (Object, "tags", Value.Tags); Swagger.Streams.Deserialize (Object, "status", Value.Status); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out PetType_Vectors.Vector) is + Value : out Pet_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : PetType; + Item : Pet_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); @@ -219,7 +219,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in UserType) is + Value : in User_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); @@ -235,7 +235,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in UserType_Vectors.Vector) is + Value : in User_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -246,7 +246,7 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out UserType) is + Value : out User_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); @@ -262,9 +262,9 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out UserType_Vectors.Vector) is + Value : out User_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : UserType; + Item : User_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); @@ -279,7 +279,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in OrderType) is + Value : in Order_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); @@ -293,7 +293,7 @@ package body Samples.Petstore.Models is procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in OrderType_Vectors.Vector) is + Value : in Order_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop @@ -304,23 +304,23 @@ package body Samples.Petstore.Models is procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out OrderType) is + Value : out Order_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "petId", Value.Pet_Id); Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity); - Swagger.Streams.Deserialize (Object, "shipDate", Value.Ship_Date); + Deserialize (Object, "shipDate", Value.Ship_Date); Swagger.Streams.Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "complete", Value.Complete); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out OrderType_Vectors.Vector) is + Value : out Order_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; - Item : OrderType; + Item : Order_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); diff --git a/samples/client/petstore/ada/src/model/samples-petstore-models.ads b/samples/client/petstore/ada/src/model/samples-petstore-models.ads index f52cb0676fc..4b0e867aa07 100644 --- a/samples/client/petstore/ada/src/model/samples-petstore-models.ads +++ b/samples/client/petstore/ada/src/model/samples-petstore-models.ads @@ -1,10 +1,10 @@ -- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- --- OpenAPI spec version: 1.0.0 +-- The version of the OpenAPI document: 1.0.0 -- -- --- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT. +-- NOTE: This package is auto generated by OpenAPI-Generator 4.2.3-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. @@ -17,32 +17,32 @@ package Samples.Petstore.Models is -- An uploaded response -- Describes the result of uploading an image resource -- ------------------------------ - type ApiResponseType is + type ApiResponse_Type is record - Code : Integer; - P_Type : Swagger.UString; - Message : Swagger.UString; + Code : Swagger.Nullable_Integer; + P_Type : Swagger.Nullable_UString; + Message : Swagger.Nullable_UString; end record; - package ApiResponseType_Vectors is + package ApiResponse_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => ApiResponseType); + Element_Type => ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in ApiResponseType); + Value : in ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in ApiResponseType_Vectors.Vector); + Value : in ApiResponse_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out ApiResponseType); + Value : out ApiResponse_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out ApiResponseType_Vectors.Vector); + Value : out ApiResponse_Type_Vectors.Vector); @@ -50,31 +50,31 @@ package Samples.Petstore.Models is -- Pet Tag -- A tag for a pet -- ------------------------------ - type TagType is + type Tag_Type is record - Id : Swagger.Long; - Name : Swagger.UString; + Id : Swagger.Nullable_Long; + Name : Swagger.Nullable_UString; end record; - package TagType_Vectors is + package Tag_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => TagType); + Element_Type => Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in TagType); + Value : in Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in TagType_Vectors.Vector); + Value : in Tag_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out TagType); + Value : out Tag_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out TagType_Vectors.Vector); + Value : out Tag_Type_Vectors.Vector); @@ -82,31 +82,31 @@ package Samples.Petstore.Models is -- Pet category -- A category for a pet -- ------------------------------ - type CategoryType is + type Category_Type is record - Id : Swagger.Long; - Name : Swagger.UString; + Id : Swagger.Nullable_Long; + Name : Swagger.Nullable_UString; end record; - package CategoryType_Vectors is + package Category_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => CategoryType); + Element_Type => Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in CategoryType); + Value : in Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in CategoryType_Vectors.Vector); + Value : in Category_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out CategoryType); + Value : out Category_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out CategoryType_Vectors.Vector); + Value : out Category_Type_Vectors.Vector); @@ -114,35 +114,35 @@ package Samples.Petstore.Models is -- a Pet -- A pet for sale in the pet store -- ------------------------------ - type PetType is + type Pet_Type is record - Id : Swagger.Long; - Category : Samples.Petstore.Models.CategoryType; + Id : Swagger.Nullable_Long; + Category : Samples.Petstore.Models.Category_Type; Name : Swagger.UString; Photo_Urls : Swagger.UString_Vectors.Vector; - Tags : Samples.Petstore.Models.TagType_Vectors.Vector; - Status : Swagger.UString; + Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector; + Status : Swagger.Nullable_UString; end record; - package PetType_Vectors is + package Pet_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => PetType); + Element_Type => Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in PetType); + Value : in Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in PetType_Vectors.Vector); + Value : in Pet_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out PetType); + Value : out Pet_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out PetType_Vectors.Vector); + Value : out Pet_Type_Vectors.Vector); @@ -150,37 +150,37 @@ package Samples.Petstore.Models is -- a User -- A User who is purchasing from the pet store -- ------------------------------ - type UserType is + type User_Type is record - Id : Swagger.Long; - Username : Swagger.UString; - First_Name : Swagger.UString; - Last_Name : Swagger.UString; - Email : Swagger.UString; - Password : Swagger.UString; - Phone : Swagger.UString; - User_Status : Integer; + Id : Swagger.Nullable_Long; + Username : Swagger.Nullable_UString; + First_Name : Swagger.Nullable_UString; + Last_Name : Swagger.Nullable_UString; + Email : Swagger.Nullable_UString; + Password : Swagger.Nullable_UString; + Phone : Swagger.Nullable_UString; + User_Status : Swagger.Nullable_Integer; end record; - package UserType_Vectors is + package User_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => UserType); + Element_Type => User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in UserType); + Value : in User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in UserType_Vectors.Vector); + Value : in User_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out UserType); + Value : out User_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out UserType_Vectors.Vector); + Value : out User_Type_Vectors.Vector); @@ -188,35 +188,35 @@ package Samples.Petstore.Models is -- Pet Order -- An order for a pets from the pet store -- ------------------------------ - type OrderType is + type Order_Type is record - Id : Swagger.Long; - Pet_Id : Swagger.Long; - Quantity : Integer; - Ship_Date : Swagger.Datetime; - Status : Swagger.UString; - Complete : Boolean; + Id : Swagger.Nullable_Long; + Pet_Id : Swagger.Nullable_Long; + Quantity : Swagger.Nullable_Integer; + Ship_Date : Swagger.Nullable_Date; + Status : Swagger.Nullable_UString; + Complete : Swagger.Nullable_Boolean; end record; - package OrderType_Vectors is + package Order_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, - Element_Type => OrderType); + Element_Type => Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in OrderType); + Value : in Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; - Value : in OrderType_Vectors.Vector); + Value : in Order_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out OrderType); + Value : out Order_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; - Value : out OrderType_Vectors.Vector); + Value : out Order_Type_Vectors.Vector); diff --git a/samples/client/petstore/ada/src/petstore.adb b/samples/client/petstore/ada/src/petstore.adb index 9c1db2490ad..6254252e57c 100644 --- a/samples/client/petstore/ada/src/petstore.adb +++ b/samples/client/petstore/ada/src/petstore.adb @@ -5,12 +5,10 @@ with Util.Http.Clients.Curl; with Ada.Text_IO; with Ada.Command_Line; with Ada.Calendar.Formatting; -with Ada.Strings.Unbounded; with Ada.Exceptions; -procedure Test is +procedure Petstore is use Ada.Text_IO; - use type Ada.Strings.Unbounded.Unbounded_String; procedure Usage; procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type); @@ -65,7 +63,7 @@ procedure Test is Need_Indent := False; Put ("URLs : "); for Url of Pet.Photo_Urls loop - Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Url.Value)); + Put_Line ((if Need_Indent then " " else "") & Url); Need_Indent := True; end loop; end if; @@ -130,10 +128,10 @@ procedure Test is begin for I in Arg .. Arg_Count loop declare - Status : Swagger.Nullable_UString_Vectors.Vector; + Status : Swagger.UString_Vectors.Vector; P : constant String := Ada.Command_Line.Argument (I); begin - Status.Append ((Is_Null => False, Value => Swagger.To_UString (P))); + Status.Append (New_Item => P); C.Find_Pets_By_Status (Status, Pets); for Pet of Pets loop Print_Pet (Pet); @@ -143,17 +141,17 @@ procedure Test is end List_Pet; procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type) is - List : Swagger.Nullable_Integer_Map; - Iter : Swagger.Nullable_Integer_Maps.Cursor; + List : Swagger.Integer_Map; + Iter : Swagger.Integer_Maps.Cursor; begin C.Get_Inventory (List); Ada.Text_IO.Put_Line ("Inventory size " & Natural'Image (Natural (List.Length))); Iter := List.First; - while Swagger.Nullable_Integer_Maps.Has_Element (Iter) loop - Put (Swagger.Nullable_Integer_Maps.Key (Iter)); + while Swagger.Integer_Maps.Has_Element (Iter) loop + Put (Swagger.Integer_Maps.Key (Iter)); Set_Col (70); - Put_Line (Natural'Image (Swagger.Nullable_Integer_Maps.Element (Iter).Value)); - Swagger.Nullable_Integer_Maps.Next (Iter); + Put_Line (Natural'Image (Swagger.Integer_Maps.Element (Iter))); + Swagger.Integer_Maps.Next (Iter); end loop; end List_Inventory; @@ -271,4 +269,4 @@ begin Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E)); end; -end Test; +end Petstore;