From dcf5643dd5e50b42d5012d6a0927102c8f80eaf3 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Fri, 22 Aug 2025 08:23:39 +0200 Subject: [PATCH 1/5] Replace CompileService with CompileOperation --- APLSource/Core/CompileOperation.aplf | 74 +++++++++++++++++++++++++++ APLSource/Core/CompilePaths.aplf | 25 +++++---- APLSource/Core/CompileService.aplf | 76 ---------------------------- 3 files changed, 90 insertions(+), 85 deletions(-) create mode 100644 APLSource/Core/CompileOperation.aplf delete mode 100644 APLSource/Core/CompileService.aplf diff --git a/APLSource/Core/CompileOperation.aplf b/APLSource/Core/CompileOperation.aplf new file mode 100644 index 0000000..995b285 --- /dev/null +++ b/APLSource/Core/CompileOperation.aplf @@ -0,0 +1,74 @@ + r←depth CompileOperation(command cmdObj name baseurl path schema toolsdir);reqBody;args;f;hasRequestBody;hasParameters;hasSharedParams;classname;classref;lines;hasNestClass;toolspath;componentspath + r←⍬ + r,←⊂':Class ',name + toolspath←(∊depth/⊂'##.'),toolsdir + componentspath←(∊depth/⊂'##.'),'components' + r,←⊂':Include ',toolspath + r,←⊂'' + r,←⊂' (⎕IO ⎕ML)←1' + r,←⊂'' + r,←⊂' :Field Private Shared ∆schema←⎕JSON ',Quote ⎕JSON cmdObj + r,←⊂' :Field Private Shared ∆components←',componentspath + r,←⊂' :Field Private Shared ∆baseurl←',Quote baseurl + r,←⊂' :Field Private Shared ∆path←',Quote path + + hasSharedParams←⊃0≠cmdObj.##.⎕NC'parameters' + (hasRequestBody hasParameters)←0≠cmdObj.⎕NC'requestBody' 'parameters' + r,←⊂'' + f←⍬ + f,←⊂'r←clt Run args' + f,←⊂':Access Public Shared' + f,←⊂'⍝ (Don''t modify, generated by ',(⊃⎕XSI),')' + f,←{6::'' ⋄ (⊂'⍝ Summary:'),CommentLines ⍵.summary}cmdObj + f,←{6::'' ⋄ (⊂'⍝ Description:'),CommentLines ⍵.description}cmdObj + f,←⊂'⍝ clt: obj, HttpClient instance' + :If hasParameters⍱hasSharedParams + :If hasRequestBody + f,←(⊂'⍝ args: obj, Request body'),{6::'' ⋄ CommentLines ⍵.description}cmdObj.requestBody + :Else + f,←⊂'⍝ args: bs, dummy' + :EndIf + :Else + reqBody←⍬ + :If hasRequestBody + reqBody←⎕NS'' + reqBody.name←'requestBody' + reqBody.description←{6::'' ⋄ ⍵.description}cmdObj.requestBody + reqBody.schema←schema ResolveRef cmdObj.requestBody.content + :EndIf + args←∊((hasParameters hasSharedParams)/cmdObj cmdObj.##).parameters,reqBody + f,←⊂'⍝ args: mv, parameters, vector of shape ',⍕(≢args) + f,←1↓¨↓⍕↑(⍕¨⍳≢args){ + paramschema←schema ResolveRef ⍵ + aplType←('integer' 'string' 'boolean' 'array' 'object'⍳⊂paramschema.type)⊃'ns' 'cv' 'bs' 'mv' 'obj' 'obj' + desc←{6::'' ⋄ ',',⍵.description~⎕UCS 10 13}⍵ + ('⍝ ',⍺,'⊃args:')(aplType,',')⍵.name paramschema.type desc + }¨args + :EndIf + f,←⊂'r←clt execute ',(Quote command),' ∆schema args' + f,←⊂'' + r,←(⊂' '),¨(1⌽'∇ ' '∇ ',(¯2+≢f)⍴⊂' '),¨f + :If hasRequestBody + :If hasNestClass←0≠⎕NC'cmdObj.requestBody.content.⍙application⍙47⍙json.schema.properties' + classname←'RequestBodyClass' + lines←(depth+1)CompileObject toolsdir cmdObj.requestBody.content.⍙application⍙47⍙json.schema classname + classref←'''',classname,'''' + :Else + classref←'∆schema.requestBody.content' + :EndIf + r,←⊂'' + f←⍬ + f,←⊂'r←NewRequestBody' + f,←⊂':Access Public Shared' + f,←⊂'⍝ (Don''t modify, generated by ',(⊃⎕XSI),')' + f,←⊂'⍝ r: Returns a requestbody object.' + f,←{6::'' ⋄ (⊂'⍝ Description:'),CommentLines ⍵.description}cmdObj.requestBody + f,←⊂'r←commandRequestBody ',classref + f,←⊂'' + r,←(⊂' '),¨(1⌽'∇ ' '∇ ',(¯2+≢f)⍴⊂' '),¨f + :If hasNestClass + r,←(⊂''),(⊂' '),¨lines + :EndIf + :EndIf + r,←⊂'' + r,←⊂':EndClass ⍝ ',name diff --git a/APLSource/Core/CompilePaths.aplf b/APLSource/Core/CompilePaths.aplf index 2b4fb61..3c7ba1f 100644 --- a/APLSource/Core/CompilePaths.aplf +++ b/APLSource/Core/CompilePaths.aplf @@ -1,17 +1,24 @@ - CompilePaths(schema svcdir toolsdir);paths;pathsdir;baseUrl;pathObjs;pathUrls;names;name;pathUrl;pathObj;depth;lines + CompilePaths(schema svcdir toolsdir);paths;baseUrl;pathObjs;pathUrls;name;pathUrl;depth;lines;command;cmdObj;cmds;cmdMatrix;operationIds;cmd;pathObj;hasParameters ⍝Compile paths section of schema into APL classes →(0=schema.⎕NC'paths')/0 paths←schema.paths.⎕NL ¯9 →(0=≢paths)/0 - pathsdir←svcdir,'/paths/' - 3 ⎕MKDIR pathsdir baseUrl←{6::'' ⋄ ⊃⍵.servers.url}schema - (pathObjs pathUrls names)←⊂'' + (pathObjs pathUrls)←⊂'' pathObjs←schema.paths.⍎¨paths pathUrls←JsonConvertNames paths - names←GenerateNamesFromPath pathUrls - :For name pathUrl pathObj :InEach names pathUrls pathObjs - depth←2 - lines←depth CompileService pathObj name baseUrl pathUrl schema toolsdir - (⊂lines)⎕NPUT(pathsdir,name,'.aplc')1 + cmds←pathObjs.⎕NL ¯9 + cmdMatrix←⊃⍪/pathUrls{(⊂⍺),⍵}¨pathObjs{⍵,⍺,⍪⍺⍎¨⍵}¨cmds + operationIds←(,/cmdMatrix[;2 1]){0=⍵.⎕NC'operationId':⍺ ⋄ ⍵.operationId}¨cmdMatrix[;4] + cmdMatrix,←GenerateNamesFromPath operationIds + :For pathUrl cmd pathObj cmdObj name :In ↓cmdMatrix + hasParameters←0<(pathObj cmdObj).⎕NC⊂⊂'parameters' + :If >/hasParameters + cmdObj.parameters←pathObj.parameters + :ElseIf ∧/hasParameters + cmdObj.parameters,←pathObj.parameters + :EndIf + depth←1 + lines←depth CompileOperation cmd cmdObj name baseUrl pathUrl schema toolsdir + (⊂lines)⎕NPUT(svcdir,'/',name,'.aplc')1 :EndFor diff --git a/APLSource/Core/CompileService.aplf b/APLSource/Core/CompileService.aplf deleted file mode 100644 index 41e2e14..0000000 --- a/APLSource/Core/CompileService.aplf +++ /dev/null @@ -1,76 +0,0 @@ - r←depth CompileService(obj name baseurl path schema toolsdir);commands;cmdObj;command;reqBody;args;f;hasRequestBody;hasParameters;hasSharedParams;classname;classref;lines;hasNestClass;toolspath - r←⍬ - r,←⊂':Class ',name - toolspath←(∊depth/⊂'##.'),toolsdir - r,←⊂':Include ',toolspath - r,←⊂'' - r,←⊂' (⎕IO ⎕ML)←1' - r,←⊂'' - r,←⊂' :Field Private Shared ∆schema←⎕JSON ',Quote ⎕JSON obj - r,←⊂' :Field Private Shared ∆baseurl←',Quote baseurl - r,←⊂' :Field Private Shared ∆path←',Quote path - - commands←obj.⎕NL ¯9 - hasSharedParams←⊃0≠obj.⎕NC'parameters' - :For command :In commands - cmdObj←obj.⍎command - (hasRequestBody hasParameters)←0≠cmdObj.⎕NC'requestBody' 'parameters' - r,←⊂'' - f←⍬ - f,←⊂'r←clt ',({(1 ⎕C⊃⍵),1↓⍵}command),' args' - f,←⊂':Access Public Shared' - f,←⊂'⍝ (Don''t modify, generated by ',(⊃⎕XSI),')' - f,←{6::'' ⋄ (⊂'⍝ Summary:'),CommentLines ⍵.summary}cmdObj - f,←{6::'' ⋄ (⊂'⍝ Description:'),CommentLines ⍵.description}cmdObj - f,←⊂'⍝ clt: obj, HttpClient instance' - :If hasParameters⍱hasSharedParams - :If hasRequestBody - f,←(⊂'⍝ args: obj, Request body'),{6::'' ⋄ CommentLines ⍵.description}cmdObj.requestBody - :Else - f,←⊂'⍝ args: bs, dummy' - :EndIf - :Else - reqBody←⍬ - :If hasRequestBody - reqBody←⎕NS'' - reqBody.name←'requestBody' - reqBody.description←{6::'' ⋄ ⍵.description}cmdObj.requestBody - reqBody.schema←schema ResolveRef cmdObj.requestBody.content - :EndIf - args←∊((hasParameters hasSharedParams)/cmdObj obj).parameters,reqBody - f,←⊂'⍝ args: mv, parameters, vector of shape ',⍕(≢args) - f,←1↓¨↓⍕↑(⍕¨⍳≢args){ - paramschema←schema ResolveRef ⍵ - aplType←('integer' 'string' 'boolean' 'array' 'object'⍳⊂paramschema.type)⊃'ns' 'cv' 'bs' 'mv' 'obj' 'obj' - desc←{6::'' ⋄ ',',⍵.description~⎕UCS 10 13}⍵ - ('⍝ ',⍺,'⊃args:')(aplType,',')⍵.name paramschema.type desc - }¨args - :EndIf - f,←⊂'r←clt execute ',(Quote command),' ∆schema.',command,' args' - f,←⊂'' - r,←(⊂' '),¨(1⌽'∇ ' '∇ ',(¯2+≢f)⍴⊂' '),¨f - :If hasRequestBody - :If hasNestClass←0≠⎕NC'cmdObj.requestBody.content.⍙application⍙47⍙json.schema.properties' - classname←({(1 ⎕C⊃⍵),1↓⍵}command),'RequestBodyClass' - lines←(depth+1)CompileObject toolsdir cmdObj.requestBody.content.⍙application⍙47⍙json.schema classname - classref←'''',classname,'''' - :Else - classref←'∆schema.',command,'.requestBody.content' - :EndIf - r,←⊂'' - f←⍬ - f,←⊂'r←New',({(1 ⎕C⊃⍵),1↓⍵}command),'RequestBody' - f,←⊂':Access Public Shared' - f,←⊂'⍝ (Don''t modify, generated by ',(⊃⎕XSI),')' - f,←⊂'⍝ r: Returns a requestbody object.' - f,←{6::'' ⋄ (⊂'⍝ Description:'),CommentLines ⍵.description}cmdObj.requestBody - f,←⊂'r←commandRequestBody ',classref - f,←⊂'' - r,←(⊂' '),¨(1⌽'∇ ' '∇ ',(¯2+≢f)⍴⊂' '),¨f - :If hasNestClass - r,←(⊂''),(⊂' '),¨lines - :EndIf - :EndIf - :EndFor - r,←⊂'' - r,←⊂':EndClass ⍝ ',name From 2d17f613531eabf21c631bd6a65eae29aae46012 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Fri, 22 Aug 2025 08:25:05 +0200 Subject: [PATCH 2/5] Use shared ref to components ns --- APLSource/Core/CompileObject.aplf | 4 +++- APLSource/Core/Tools/getComponent.aplf | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/APLSource/Core/CompileObject.aplf b/APLSource/Core/CompileObject.aplf index 7c232d8..194bfdd 100644 --- a/APLSource/Core/CompileObject.aplf +++ b/APLSource/Core/CompileObject.aplf @@ -1,12 +1,14 @@ - r←depth CompileObject(toolsdir obj name);propnames;properties;mask;f;nstdclassmask;classnames;toolspath + r←depth CompileObject(toolsdir obj name);propnames;properties;mask;f;nstdclassmask;classnames;toolspath;componentspath r←⍬ r,←⊂':Class ',name toolspath←(∊depth/⊂'##.'),toolsdir + componentspath←(∊depth/⊂'##.'),'components' r,←⊂':Include ',toolspath r,←⊂'' r,←⊂' (⎕IO ⎕ML)←1' r,←⊂'' r,←⊂' :Field Private Shared ∆schema←⎕JSON ',Quote ⎕JSON obj + r,←⊂' :Field Private Shared ∆components←',componentspath r,←⊂' :Field Private Shared ∆propertyNames←∆schema.properties.⎕NL ¯9' r,←⊂' :Field Private Shared ∆properties←∆schema.properties.⍎¨∆propertyNames' r,←⊂'' diff --git a/APLSource/Core/Tools/getComponent.aplf b/APLSource/Core/Tools/getComponent.aplf index 6221fdc..dfe2e64 100644 --- a/APLSource/Core/Tools/getComponent.aplf +++ b/APLSource/Core/Tools/getComponent.aplf @@ -1,13 +1,11 @@ - r←getComponent content;comppath;ref;root + r←getComponent content;comppath;ref ref←{ 2=⍵.⎕NC'⍙⍙36⍙ref':⍵.⍙⍙36⍙ref ⍵.(⍎⊃⎕NL ¯9).schema.⍙⍙36⍙ref }content comppath←translatePath ref - :If '#.'≡2↑comppath - root←⊃'^(.+\.)(?:components|paths)'⎕S'\1'⊢⍕(⊃⊃⎕CLASS ⎕THIS) - :AndIf 0≠≢root - r←⍎root,2↓comppath + :If '#.components'(⊃⍷)comppath + r←⍎'∆',2↓comppath :EndIf ⍝ From 2b8dbf3b8eb4a81667c1ab40426d8edc0a0e13a3 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Fri, 22 Aug 2025 08:25:21 +0200 Subject: [PATCH 3/5] Improve naming of operations --- APLSource/Core/GenerateNamesFromPath.aplf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/APLSource/Core/GenerateNamesFromPath.aplf b/APLSource/Core/GenerateNamesFromPath.aplf index a0a528e..c139ccc 100644 --- a/APLSource/Core/GenerateNamesFromPath.aplf +++ b/APLSource/Core/GenerateNamesFromPath.aplf @@ -3,7 +3,8 @@ string←'''(?:[^\r\n'']|'''')*''' pattern←'(\((?:',string,'|[^()'']|(?1))*\))' ⍝ group: (nested)parens - names←'^_?.'⎕R'\u0'⊢'^/'pattern'((/{\w+})+)' '[^A-Za-zÀ-ÖØ-Ýß-öø-üþ∆⍙Ⓐ-Ⓩ0-9]'⎕R'' 'Key' 'Key' '_'⊢⊆paths + names←'^/'pattern'/(\w)(\w*)' '[^A-Za-zÀ-ÖØ-Ýß-öø-üþ∆⍙Ⓐ-Ⓩ0-9]'⎕R'' 'Key' '\u1\2' '_'⊢⊆paths~¨⊂'{}' + names←'^_?.' '_(.)'⎕R'\u0' '\u1'⊢names ⍝ PascalCase names←{⊆⊢/⍵⌷⍨⊂⍋⍵}⊃⍪/{1=≢⍵:⊂⍵,⍪⍺ ⋄ ⊂⍵,⍪⍺,¨'_',∘⍕¨⍳≢⍵}⌸names ⍝ add nr suffix for duplicates r←names ⍝ From 67e012d5b71437364a0707e5dd466e3e0b2b5c07 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Fri, 22 Aug 2025 08:25:56 +0200 Subject: [PATCH 4/5] Add shared properties into operations --- APLSource/Core/Tools/execute.aplf | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/APLSource/Core/Tools/execute.aplf b/APLSource/Core/Tools/execute.aplf index 604e389..c757d4f 100644 --- a/APLSource/Core/Tools/execute.aplf +++ b/APLSource/Core/Tools/execute.aplf @@ -1,20 +1,18 @@ -r←clt execute(command cmdObj args);qp;qpmask;urlmask;mask;res;paramscnt;paramnames;hasParams;hasReqBody;in;rc;resp;csrf;etag;payload;hasSharedParams;paramobjs;msg;explode;vals +r←clt execute(command cmdObj args);qp;qpmask;urlmask;mask;res;paramscnt;paramnames;hasParams;hasReqBody;in;rc;resp;csrf;etag;payload;msg;explode;vals ⍝clt: obj, HttpClient instance clt.Command←command clt.BaseURL{0=≢⍺:⍵ ⋄ ⍺}←∆baseurl clt.URL←∆path clt.Params←'' - hasSharedParams←⊃0≠cmdObj.##.⎕NC'parameters' hasParams hasReqBody←0≠cmdObj.⎕NC'parameters' 'requestBody' - :If (hasParams∨hasSharedParams) Date: Fri, 22 Aug 2025 08:26:24 +0200 Subject: [PATCH 5/5] Update tests to match implementation --- .../UnitTests/ClassConstructor_test.aplf | 2 +- APLSource/Tests/UnitTests/Compile_test.aplf | 2 +- .../UnitTests/RequestBody_nstobj_test.aplf | 6 +++--- .../UnitTests/commandRequestBody_test.aplf | 20 +++++++++---------- .../UnitTests/execute_paramplusrqb_test.aplf | 12 +++++------ 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/APLSource/Tests/UnitTests/ClassConstructor_test.aplf b/APLSource/Tests/UnitTests/ClassConstructor_test.aplf index fafc838..d3b59ac 100644 --- a/APLSource/Tests/UnitTests/ClassConstructor_test.aplf +++ b/APLSource/Tests/UnitTests/ClassConstructor_test.aplf @@ -2,4 +2,4 @@ classfolder←TestClasses.PetstoreExpanded ⍝ Can the constructors be called without errors. (0 Try ⎕NEW)¨classfolder.components.schemas.(⍎¨⎕NL ¯9) - (0 Try ⎕NEW)¨classfolder.paths.(⍎¨⎕NL ¯9) + (0 Try ⎕NEW)¨classfolder.(⍎¨⎕NL ¯9.4) diff --git a/APLSource/Tests/UnitTests/Compile_test.aplf b/APLSource/Tests/UnitTests/Compile_test.aplf index ea1bc10..f846dc4 100644 --- a/APLSource/Tests/UnitTests/Compile_test.aplf +++ b/APLSource/Tests/UnitTests/Compile_test.aplf @@ -7,4 +7,4 @@ ⍝ Test if all components and paths were compiled into classes schema←⎕JSON⊃⎕NGET openapidir,'/','petstore-expanded.json' Assert(≢TestClasses.PetstoreExpanded.components.schemas.⎕NL ¯9.4)=≢schema.components.schemas.⎕NL ¯9 - Assert(≢TestClasses.PetstoreExpanded.paths.⎕NL ¯9)=≢schema.paths.⎕NL ¯9 + Assert(≢TestClasses.PetstoreExpanded.⎕NL ¯9.4)=+/schema.paths.(⍎¨⎕NL ¯9).(≢⎕NL ¯9) diff --git a/APLSource/Tests/UnitTests/RequestBody_nstobj_test.aplf b/APLSource/Tests/UnitTests/RequestBody_nstobj_test.aplf index 3148a34..ac59c2a 100644 --- a/APLSource/Tests/UnitTests/RequestBody_nstobj_test.aplf +++ b/APLSource/Tests/UnitTests/RequestBody_nstobj_test.aplf @@ -1,5 +1,5 @@ RequestBody_nstobj_test;inst;rqb - inst←⎕NEW TestClasses.TestODA.paths.Nestrqbody - rqb←inst.NewPostRequestBody - Assert #.Papi.Tests.UnitTests.TestClasses.TestODA.paths.Nestrqbody.PostRequestBodyClass.objectClass≡rqb.object.(⊃⊃⎕CLASS ⎕THIS) + inst←⎕NEW TestClasses.TestODA.CreateNestrqbody + rqb←inst.NewRequestBody + Assert #.Papi.Tests.UnitTests.TestClasses.TestODA.CreateNestrqbody.RequestBodyClass.objectClass≡rqb.object.(⊃⊃⎕CLASS ⎕THIS) Assert∧/'description' 'name' 'summary'∊rqb.object.⎕NL ¯2 diff --git a/APLSource/Tests/UnitTests/commandRequestBody_test.aplf b/APLSource/Tests/UnitTests/commandRequestBody_test.aplf index f2ac2bb..7a454cc 100644 --- a/APLSource/Tests/UnitTests/commandRequestBody_test.aplf +++ b/APLSource/Tests/UnitTests/commandRequestBody_test.aplf @@ -1,4 +1,4 @@ - commandRequestBody_test;oaddir;schemaFiles;schemaFile;nsname;schema;count_reqbods;count_functions;namespaces;ns;endpoints;ep;inst;reqbody;compinst;funcs + commandRequestBody_test;oaddir;schemaFiles;schemaFile;nsname;schema;count_reqbods;count_functions;namespaces;ns;endpoints;ep;reqbody;compinst;funcs ⍝ Compare count of request bodies in OAD with count of functions to get a request body in generated classes. oaddir←'./Testdata' @@ -7,15 +7,15 @@ nsname←'-(.)'⎕R'\u1'⊢'-',2⊃⎕NPARTS schemaFile schema←⎕JSON⊃⎕NGET schemaFile count_reqbods←+⌿∊{6::0 ⋄ ⍵.paths.(⍎¨⎕NL ¯9).(⍎¨⎕NL ¯9).(0≠⎕NC'requestBody')}schema - count_functions←+⌿{6::0 ⋄ ⍵.paths.(⍎¨⎕NL ¯9).(≢'RequestBody$'⎕S'%'⊢⎕NL ¯3)}TestClasses⍎nsname + count_functions←+⌿{6::0 ⋄ ⍵.(⍎¨⎕NL ¯9.4).(≢'RequestBody$'⎕S'%'⊢⎕NL ¯3)}TestClasses⍎nsname Assert count_reqbods=count_functions :EndFor ⍝ Can the commandRequestBody functions be called for each endpoint without crashing. namespaces←TestClasses.(⍎¨⎕NL ¯9) - namespaces/⍨←namespaces.(⊃9=⎕NC'paths') + namespaces/⍨←namespaces.(0<≢⎕NL ¯9.4) :For ns :In namespaces - endpoints←{0≠≢ep←⍵.paths.(⎕NL ¯9):⍎¨(⊂'⍵.paths.'),¨ep ⋄ ⍬}ns + endpoints←{0≠≢ep←⍵.(⎕NL ¯9.4):⍎¨(⊂'⍵.'),¨ep ⋄ ⍬}ns :For ep :In endpoints :If 0<≢funcs←ep.('RequestBody$'⎕S'%'⊢⎕NL ¯3) inst←⎕NEW ep @@ -25,13 +25,11 @@ :EndFor ⍝ Request body with ref - inst←⎕NEW TestClasses.PetstoreExpanded.paths.Pets - reqbody←inst.NewPostRequestBody + reqbody←TestClasses.PetstoreExpanded.AddPet.NewRequestBody compinst←⎕NEW TestClasses.PetstoreExpanded.components.schemas.NewPet - Assert compinst.(⊃⊃⎕CLASS ⎕THIS)≡reqbody.(⊃⊃⊃⎕CLASS ⎕THIS) + Assert (⎕CLASS compinst)≡(⎕CLASS reqbody) ⍝ Request body with properties - inst←⎕NEW TestClasses.Reqres.paths.Login - reqbody←inst.NewPostRequestBody - compinst←⎕NEW TestClasses.Reqres.paths.Login.PostRequestBodyClass - Assert compinst.(⊃⊃⎕CLASS ⎕THIS)≡reqbody.(⊃⊃⊃⎕CLASS ⎕THIS) + reqbody←TestClasses.Reqres.PostLogin.NewRequestBody + compinst←⎕NEW TestClasses.Reqres.PostLogin.RequestBodyClass + Assert (⎕CLASS compinst)≡(⎕CLASS reqbody) diff --git a/APLSource/Tests/UnitTests/execute_paramplusrqb_test.aplf b/APLSource/Tests/UnitTests/execute_paramplusrqb_test.aplf index 9834bbe..2090ba2 100644 --- a/APLSource/Tests/UnitTests/execute_paramplusrqb_test.aplf +++ b/APLSource/Tests/UnitTests/execute_paramplusrqb_test.aplf @@ -1,16 +1,16 @@ - execute_paramplusrqb_test;hc;inst;rqb;name + execute_paramplusrqb_test;hc;rqb;name;inst ⍝ Post request with two in query parms and a request body hc←HttpCommand.New'' - inst←⎕NEW TestClasses.TestODA.paths.Thing - rqb←inst.NewPostRequestBody + inst←TestClasses.TestODA.AddThing + rqb←inst.NewRequestBody rqb.name←name←'New' - hc(0 Try inst.Post)'id7' 'Aname'rqb + hc(0 Try inst.Run)'id7' 'Aname'rqb Assert∨/'/thing?homeId=id7&name=Aname'⍷hc.Show Assert name≡hc.Params.name ⍝ Get request with one in query parm and no req body hc←HttpCommand.New'' - inst←⎕NEW TestClasses.TestODA.paths.AnotherthingKey - hc(0 Try inst.Get)3 + inst←TestClasses.TestODA.FindAnotherthingById + hc(0 Try inst.Run)3 Assert∨/'/anotherthing/?limit=3'⍷hc.Show