Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
Ada.server-skeleton-body.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
pragma Warnings (Off, "*is not referenced");
with {{openApiPackageName}}.Streams;
with {{openApiPackageName}}.Servers.Operation;
package body {{package}}.Skeletons is
pragma Style_Checks ("-mr");
pragma Warnings (Off, "*use clause for package*");
use {{openApiPackageName}}.Streams;
package body Skeleton is
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
package API_{{operationId}} is
new {{openApiPackageName}}.Servers.Operation
(Handler => {{operationId}},
Method => {{openApiPackageName}}.Servers.{{httpMethod}},
URI => URI_Prefix & "{{path}}");
-- {{summary}}
procedure {{operationId}}
(Req : in out {{openApiPackageName}}.Servers.Request'Class;
Reply : in out {{openApiPackageName}}.Servers.Response'Class;
Stream : in out {{openApiPackageName}}.Servers.Output_Stream'Class;
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
{{#hasBodyParam}}
Input : {{openApiPackageName}}.Value_Type;
{{/hasBodyParam}}
Impl : Implementation_Type;
{{#allParams}}
{{paramName}} : {{dataType}};
{{/allParams}}
{{#returnType}}
Result : {{.}};
{{/returnType}}
begin
{{#vendorExtensions.x-auth-scopes}}
if not Context.Is_Authenticated then
Context.Set_Error (401, "Not authenticated");
return;
end if;
{{#scopes}}
if not Context.Has_Permission (ACL_{{ident}}.Permission) then
Context.Set_Error (403, "Permission denied");
return;
end if;
{{/scopes}}
{{/vendorExtensions.x-auth-scopes}}
{{#queryParams}}
{{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}", {{paramName}});
{{/queryParams}}
{{#pathParams}}
{{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}, {{paramName}});
{{/pathParams}}
{{#hasFormParams}}
{{#formParams}}
{{openApiPackageName}}.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}});
{{/formParams}}
{{/hasFormParams}}
{{#hasParams}}
{{#hasBodyParam}}
{{openApiPackageName}}.Servers.Read (Req, Input);
{{#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}}
Deserialize (Input, "{{baseName}}", {{paramName}});{{/isLong}}{{/isFile}}{{/vendorExtensions.x-is-model-type}}{{/bodyParams}}
{{/hasBodyParam}}
Impl.{{operationId}}
({{#allParams}}{{paramName}}{{^-last}},
{{/-last}}{{/allParams}}{{#returnType}}{{#hasParams}}, {{/hasParams}}Result{{/returnType}}, Context);
{{/hasParams}}
{{^hasParams}}
{{#returnType}}
Impl.{{operationId}} (Result, Context);
{{/returnType}}
{{^returnType}}
Impl.{{operationId}} (Context);
{{/returnType}}
{{/hasParams}}
{{#returnType}}
if Context.Get_Status = 200 then
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
Stream.End_Document;
end if;{{/returnType}}
end {{operationId}};
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
procedure Register (Server : in out {{openApiPackageName}}.Servers.Application_Type'Class) is
begin
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{openApiPackageName}}.Servers.Register (Server, API_{{operationId}}.Definition);
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
end Register;
end Skeleton;
package body Shared_Instance is
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
-- {{summary}}
procedure {{operationId}}
(Req : in out {{openApiPackageName}}.Servers.Request'Class;
Reply : in out {{openApiPackageName}}.Servers.Response'Class;
Stream : in out {{openApiPackageName}}.Servers.Output_Stream'Class;
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
{{#hasBodyParam}}
Input : {{openApiPackageName}}.Value_Type;
{{/hasBodyParam}}
{{#allParams}}
{{paramName}} : {{dataType}};
{{/allParams}}
{{#returnType}}
Result : {{.}};
{{/returnType}}
begin
{{#vendorExtensions.x-auth-scopes}}
if not Context.Is_Authenticated then
Context.Set_Error (401, "Not authenticated");
return;
end if;
{{#scopes}}
if not Context.Has_Permission (ACL_{{ident}}.Permission) then
Context.Set_Error (403, "Permission denied");
return;
end if;
{{/scopes}}
{{/vendorExtensions.x-auth-scopes}}
{{#queryParams}}
{{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}", {{paramName}});
{{/queryParams}}
{{#pathParams}}
{{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}, {{paramName}});
{{/pathParams}}
{{#hasFormParams}}
{{#formParams}}
{{openApiPackageName}}.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}});
{{/formParams}}
{{/hasFormParams}}
{{#hasParams}}
{{#hasBodyParam}}
{{openApiPackageName}}.Servers.Read (Req, Input);
{{#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}}
Deserialize (Input, "{{baseName}}", {{paramName}});{{/isLong}}{{/isFile}}{{/vendorExtensions.x-is-model-type}}{{/bodyParams}}
{{/hasBodyParam}}
Server.{{operationId}}
({{#allParams}}{{paramName}}{{^-last}},
{{/-last}}{{/allParams}}{{#returnType}}{{#hasParams}}, {{/hasParams}}Result{{/returnType}}, Context);
{{/hasParams}}
{{^hasParams}}
{{#returnType}}
Server.{{operationId}} (Result, Context);
{{/returnType}}
{{^returnType}}
Server.{{operationId}} (Context);
{{/returnType}}
{{/hasParams}}
{{#returnType}}
if Context.Get_Status = 200 then
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
Stream.End_Document;
end if;{{/returnType}}
end {{operationId}};
package API_{{operationId}} is
new {{openApiPackageName}}.Servers.Operation
(Handler => {{operationId}},
Method => {{openApiPackageName}}.Servers.{{httpMethod}},
URI => URI_Prefix & "{{path}}");
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
procedure Register (Server : in out {{openApiPackageName}}.Servers.Application_Type'Class) is
begin
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{openApiPackageName}}.Servers.Register (Server, API_{{operationId}}.Definition);
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
end Register;
protected body Server is
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
-- {{summary}}
{{#hasParams}}
procedure {{operationId}}
({{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
{{/-last}}{{/allParams}}{{#returnType}};
Result : out {{.}}{{/returnType}};
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
begin
Impl.{{operationId}}
({{#allParams}}{{paramName}}{{^-last}},
{{/-last}}{{/allParams}}{{#returnType}},
Result{{/returnType}},
Context);
end {{operationId}};
{{/hasParams}}
{{^hasParams}}
{{#returnType}}
procedure {{operationId}} (Result : out {{returnType}};
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
begin
Impl.{{operationId}} (Result, Context);
end {{operationId}};
{{/returnType}}
{{^returnType}}
procedure {{operationId}} (Context : in out {{openApiPackageName}}.Servers.Context_Type) is
begin
Impl.{{operationId}} (Context);
end {{operationId}};
{{/returnType}}
{{/hasParams}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
end Server;
end Shared_Instance;
end {{package}}.Skeletons;