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}} {{>licenseInfo}}
pragma Warnings (Off, "*is not referenced");
with Swagger.Streams; with Swagger.Streams;
package body {{package}}.Clients is package body {{package}}.Clients is
pragma Style_Checks ("-mr");
{{#apiInfo}} {{#apiInfo}}
{{#apis}} {{#apis}}
{{#operations}} {{#operations}}

View File

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

View File

@ -3,12 +3,11 @@ abstract project Config is
type Yes_No is ("yes", "no"); 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"); type Build_Type is ("distrib", "debug", "optimize", "profile", "coverage");
Mode : Mode_Type := external ("MODE", "debug"); Mode : Build_Type := external ("BUILD", "debug");
Coverage : Yes_No := External ("COVERAGE", "no");
Processors := External ("PROCESSORS", "1"); Processors := External ("PROCESSORS", "1");
package Builder is package Builder is
@ -29,7 +28,12 @@ abstract project Config is
when "debug" => when "debug" =>
for Default_Switches ("Ada") use defaults & warnings 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" => when "optimize" =>
for Default_Switches ("Ada") use defaults & warnings for Default_Switches ("Ada") use defaults & warnings
@ -37,13 +41,7 @@ abstract project Config is
when "profile" => when "profile" =>
for Default_Switches ("Ada") use defaults & warnings & ("-pg"); 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 case;
end compiler; end compiler;
@ -69,16 +67,13 @@ abstract project Config is
when "optimize" => when "optimize" =>
for Default_Switches ("Ada") use ("-Wl,--gc-sections"); for Default_Switches ("Ada") use ("-Wl,--gc-sections");
when "coverage" =>
for Default_Switches ("ada") use ("-fprofile-arcs");
when others => when others =>
null; null;
end case; 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 package Ide is

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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