arazzo-runner 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +12 -2
  2. package/package.json +2 -2
  3. package/src/Arazzo.js +45 -13
package/README.md CHANGED
@@ -63,6 +63,12 @@ jq --arg password "$secret_password" '.workflowId1.password = $password' input.j
63
63
 
64
64
  Obviously, if you have a lot of secret variables that need adding as inputs, then you might need to write a script that can alter the `input.json` file for you within your CI/CD runner.
65
65
 
66
+ ## OpenAPI Parameters
67
+
68
+ OpenAPI Documents allow you to specify [`header`, `path` and `query` parameters](https://spec.openapis.org/oas/latest.html#parameter-object) in myriad of styles. This Arazzo Runner will respect your styling and send the format to the server as specified by your OpenAPI document.
69
+
70
+ It currently does not follow the `allowEmptyValue`, `allowReserved` or the `content` keywords currently.
71
+
66
72
  ## Logging And Reporting
67
73
 
68
74
  ### Logging
@@ -93,14 +99,18 @@ Work on Reporting still needs completeing.
93
99
 
94
100
  ## Still unsupported
95
101
 
96
- ### OpenAPI Params
102
+ ### PathOperation
97
103
 
98
- OpenAPI parameter types with style and explode are not quite supported yet
104
+ Accessing an OpenAPI operation by Operation Path `'{$sourceDescriptions.petstoreDescription.url}#/paths/~1pet~1findByStatus/get'` does not work currently
99
105
 
100
106
  ### OpenAPI Servers on various levels
101
107
 
102
108
  This pulls from the top level servers object of an OpenAPI Document. Server variables do not work either.
103
109
 
110
+ ### OpenAPI server variables
111
+
112
+ OpenAPI server variables currently do not work
113
+
104
114
  ### JSONPath and XPath criteria objects
105
115
 
106
116
  Criteria Objects set as type JSON Path or XPath do not work
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arazzo-runner",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A runner to run through Arazzo Document workflows",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,7 +41,7 @@
41
41
  "@swaggerexpert/json-pointer": "^2.10.2",
42
42
  "ajv": "^8.17.1",
43
43
  "jsonpath": "^1.1.1",
44
- "openapi-params": "^0.0.4",
44
+ "openapi-params": "^0.0.5",
45
45
  "stream-chain": "^3.4.0",
46
46
  "stream-json": "^1.9.1"
47
47
  }
package/src/Arazzo.js CHANGED
@@ -68,7 +68,6 @@ class Arazzo extends Document {
68
68
  } catch (err) {
69
69
  if (err.name === "AbortError") {
70
70
  if (err.goto) {
71
- // console.log("goto error");
72
71
  await this.handleGotoRule(err.goto);
73
72
  }
74
73
  } else {
@@ -692,8 +691,6 @@ class Arazzo extends Document {
692
691
 
693
692
  if (this.retryLimits[whatNext.name] === 0)
694
693
  this.retrySet.delete(whatNext.name);
695
-
696
- // console.log("I need to return here after retrying");
697
694
  }
698
695
 
699
696
  /**
@@ -738,13 +735,14 @@ class Arazzo extends Document {
738
735
  * @private
739
736
  */
740
737
  mapParameters() {
741
- const headers = new Headers();
742
- const queryParams = new URLSearchParams();
743
- const pathParams = {};
738
+ const headersObj = new Headers();
739
+ const headers = new URLParams();
740
+ const queryParams = new URLParams();
741
+ const pathParams = new URLParams();
744
742
 
745
743
  for (const param of this.step?.parameters || []) {
746
744
  const operationDetailParam =
747
- this.sourceDescription.operationDetails?.parameters
745
+ this.sourceDescriptionFile.operationDetails?.parameters
748
746
  .filter((obj) => obj.name === param.name && obj.in === param.in)
749
747
  .at(0);
750
748
 
@@ -752,27 +750,61 @@ class Arazzo extends Document {
752
750
 
753
751
  switch (param.in) {
754
752
  case "header":
755
- headers.append(param.name, value);
753
+ const headerStyle = operationDetailParam?.style || "simple";
754
+ const headerExplode = operationDetailParam?.explode || false;
755
+ headers.append(param.name, value, {
756
+ style: headerStyle,
757
+ explode: headerExplode,
758
+ });
759
+ for (const [header, value] of headers) {
760
+ if (header === param.name) {
761
+ headersObj.append(param.name, value);
762
+ }
763
+ }
756
764
 
757
765
  break;
758
766
 
759
767
  case "path":
760
768
  for (const operation of this.operations) {
761
- operation.url = operation.url.replace(`{${param.name}}`, value);
762
- Object.assign(pathParams, { [param.name]: value });
769
+ const pathStyle = operationDetailParam?.style || "simple";
770
+ const pathExplode = operationDetailParam?.explode || false;
771
+ pathParams.append(param.name, value, {
772
+ style: pathStyle,
773
+ explode: pathExplode,
774
+ });
775
+ for (const [name, value] of pathParams.entries()) {
776
+ operation.url = operation.url.replace(`{${name}}`, value);
777
+ }
778
+ // operation.url = operation.url.replace(`{${param.name}}`, value);
779
+ // Object.assign(pathParams, { [param.name]: value });
763
780
  }
764
781
  break;
765
782
 
766
783
  case "query":
767
- queryParams.append(param.name, value);
784
+ // queryParams.append(param.name, value);
785
+ const style = operationDetailParam?.style || "form";
786
+ let explode = false;
787
+ if (Object.hasOwn(operationDetailParam, "explode")) {
788
+ explode = operationDetailParam.explode;
789
+ } else {
790
+ if (style === "form") {
791
+ explode = true;
792
+ }
793
+ }
794
+ // const explode = operationDetailParam?.explode || false;
795
+ queryParams.append(param.name, value, {
796
+ style: style,
797
+ explode: explode,
798
+ });
768
799
  break;
769
800
  }
770
801
  }
771
802
 
772
- this.expression.addToContext("request.path", pathParams);
803
+ this.addParamsToContext(pathParams, "path", "request");
804
+ // this.expression.addToContext("request.path", pathParams);
773
805
 
774
806
  for (const operation of this.operations) {
775
- operation.headers = headers;
807
+ operation.headers = headersObj;
776
808
  operation.queryParams = queryParams;
777
809
  }
778
810
  }