Fix #8640: [BUG] [Ada] Server skeleton does not compile when an operation has no parameter (#8641)

- add missing 'use Swagger.Streams;' clause
- add Style_Checks pragma to fix style compilation warnings in generated Ada code
- fix spurious spaces in licence headers that cause Ada style compilation warning
- update the default GNAT project config
This commit is contained in:
Stephane Carrez 2021-02-08 04:20:15 +01:00 committed by GitHub
parent c5ddf463c4
commit a06af89be9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 22 deletions

View File

@ -1,6 +1,8 @@
{{>licenseInfo}}
pragma Warnings (Off, "*is not referenced");
with Swagger.Streams;
package body {{package}}.Clients is
pragma Style_Checks ("-mr");
{{#apiInfo}}
{{#apis}}
{{#operations}}

View File

@ -4,6 +4,7 @@
with {{package}}.Models;
with Swagger.Clients;
package {{package}}.Clients is
pragma Style_Checks ("-mr");
type Client_Type is new Swagger.Clients.Client_Type with null record;

View File

@ -3,17 +3,16 @@ abstract project Config is
type Yes_No is ("yes", "no");
type Library_Type_Type is ("relocatable", "static");
type Library_Type_Type is ("relocatable", "static", "static-pic");
type Mode_Type is ("distrib", "debug", "optimize", "profile");
Mode : Mode_Type := external ("MODE", "debug");
type Build_Type is ("distrib", "debug", "optimize", "profile", "coverage");
Mode : Build_Type := external ("BUILD", "debug");
Coverage : Yes_No := External ("COVERAGE", "no");
Processors := External ("PROCESSORS", "1");
package Builder is
case Mode is
when "debug" =>
when "debug" =>
for Default_Switches ("Ada") use ("-g", "-j" & Processors);
when others =>
for Default_Switches ("Ada") use ("-g", "-O2", "-j" & Processors);
@ -29,7 +28,12 @@ abstract project Config is
when "debug" =>
for Default_Switches ("Ada") use defaults & warnings
& ("-gnata", "-gnatVaMI", "-gnaty3abcefhiklmnprstxM99");
& ("-gnata", "-gnatVaMI", "-gnaty3abcefhiklmnprstxM127");
when "coverage" =>
for Default_Switches ("Ada") use defaults & warnings
& ("-gnata", "-gnatVaMI", "-gnaty3abcefhiklmnprstxM127",
"-fprofile-arcs", "-ftest-coverage");
when "optimize" =>
for Default_Switches ("Ada") use defaults & warnings
@ -37,13 +41,7 @@ abstract project Config is
when "profile" =>
for Default_Switches ("Ada") use defaults & warnings & ("-pg");
end case;
case Coverage is
when "yes" =>
for Default_Switches ("ada") use Compiler'Default_Switches ("Ada") &
("-fprofile-arcs", "-ftest-coverage");
when others =>
end case;
end compiler;
@ -69,18 +67,15 @@ abstract project Config is
when "optimize" =>
for Default_Switches ("Ada") use ("-Wl,--gc-sections");
when "coverage" =>
for Default_Switches ("ada") use ("-fprofile-arcs");
when others =>
null;
end case;
case Coverage is
when "yes" =>
for Default_Switches ("ada") use Linker'Default_Switches ("ada") &
("-fprofile-arcs");
when others =>
end case;
end linker;
end linker;
package Ide is
for VCS_Kind use "git";
end Ide;

View File

@ -2,7 +2,7 @@
-- {{{appDescription}}}
--
-- {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
-- {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
--{{#infoEmail}} Contact: {{{infoEmail}}}{{/infoEmail}}
--
-- NOTE: This package is auto generated by OpenAPI-Generator {{{generatorVersion}}}.
-- https://openapi-generator.tech

View File

@ -1,6 +1,9 @@
{{>licenseInfo}}
package body {{package}}.Models is
pragma Style_Checks ("-mr");
pragma Warnings (Off, "*use clause for package*");
use Swagger.Streams;

View File

@ -4,6 +4,7 @@
with Swagger.Streams;
with Ada.Containers.Vectors;
package {{package}}.Models is
pragma Style_Checks ("-mr");
{{#orderedModels}}{{#model}}{{^isArray}}
{{#title}} -- ------------------------------

View File

@ -1,7 +1,12 @@
{{>licenseInfo}}
pragma Warnings (Off, "*is not referenced");
with Swagger.Streams;
with Swagger.Servers.Operation;
package body {{package}}.Skeletons is
pragma Style_Checks ("-mr");
pragma Warnings (Off, "*use clause for package*");
use Swagger.Streams;
package body Skeleton is
@ -58,7 +63,7 @@ package body {{package}}.Skeletons is
{{#hasParams}}
{{#hasBodyParam}}
Swagger.Servers.Read (Req, Input);
{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
{{package}}.Models.Deserialize (Input, "{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{#isFile}}
-- TODO: Serialize (Input.Stream, "{{basename}}", {{paramName}});{{/isFile}}{{^isFile}}{{^isLong}}
Deserialize (Input, "{{baseName}}", {{paramName}});{{/isLong}}{{#isLong}}

View File

@ -1,10 +1,14 @@
{{>licenseInfo}}
{{#imports}}with {{import}};
{{/imports}}
pragma Warnings (Off, "*is not referenced");
pragma Warnings (Off, "*no entities of*are referenced");
with Swagger.Servers;
with {{package}}.Models;
with Security.Permissions;
package {{package}}.Skeletons is
pragma Style_Checks ("-mr");
pragma Warnings (Off, "*use clause for package*");
use {{package}}.Models;
type Server_Type is limited interface;
{{#authMethods}}{{#scopes}}

View File

@ -15,6 +15,7 @@ with Swagger.Servers;
with {{package}}.Models;
with {{package}}.Skeletons;
package {{package}}.Servers is
pragma Warnings (Off, "*use clause for package*");
use {{package}}.Models;
type Server_Type is limited new {{package}}.Skeletons.Server_Type with null record;