@swaggerexpert/arazzo-runtime-expression 1.0.0

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 (39) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +10 -0
  3. package/README.md +290 -0
  4. package/SECURITY.md +15 -0
  5. package/cjs/apg-lite.cjs +1221 -0
  6. package/cjs/extract.cjs +21 -0
  7. package/cjs/index.cjs +13 -0
  8. package/cjs/parse/callbacks/body-reference.cjs +14 -0
  9. package/cjs/parse/callbacks/expression.cjs +15 -0
  10. package/cjs/parse/callbacks/header-reference.cjs +14 -0
  11. package/cjs/parse/callbacks/json-pointer.cjs +14 -0
  12. package/cjs/parse/callbacks/name.cjs +14 -0
  13. package/cjs/parse/callbacks/parameter-name.cjs +14 -0
  14. package/cjs/parse/callbacks/path-reference.cjs +14 -0
  15. package/cjs/parse/callbacks/query-reference.cjs +14 -0
  16. package/cjs/parse/callbacks/reference-token.cjs +14 -0
  17. package/cjs/parse/callbacks/source.cjs +14 -0
  18. package/cjs/parse/callbacks/token.cjs +15 -0
  19. package/cjs/parse/index.cjs +40 -0
  20. package/cjs/runtime-expression.cjs +779 -0
  21. package/cjs/test.cjs +15 -0
  22. package/es/extract.mjs +17 -0
  23. package/es/index.mjs +4 -0
  24. package/es/parse/callbacks/body-reference.mjs +10 -0
  25. package/es/parse/callbacks/expression.mjs +11 -0
  26. package/es/parse/callbacks/header-reference.mjs +10 -0
  27. package/es/parse/callbacks/json-pointer.mjs +10 -0
  28. package/es/parse/callbacks/name.mjs +10 -0
  29. package/es/parse/callbacks/parameter-name.mjs +10 -0
  30. package/es/parse/callbacks/path-reference.mjs +10 -0
  31. package/es/parse/callbacks/query-reference.mjs +10 -0
  32. package/es/parse/callbacks/reference-token.mjs +10 -0
  33. package/es/parse/callbacks/source.mjs +10 -0
  34. package/es/parse/callbacks/token.mjs +10 -0
  35. package/es/parse/index.mjs +35 -0
  36. package/es/runtime-expression.mjs +775 -0
  37. package/es/test.mjs +10 -0
  38. package/package.json +82 -0
  39. package/types/index.d.ts +54 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ @swaggerexpert/arazzo-runtime-expression
2
+ Copyright 2025, Vladimír Gorej
3
+ @swaggerexpert/arazzo-runtime-expression is licensed under Apache 2.0 license.
4
+ Copy of the Apache 2.0 license can be found in `LICENSE` file.
5
+
6
+ Arazzo Specification 1.0.1
7
+ Copyright The Linux Foundation
8
+ Fragments of the specification text are embedded in `README.md`.
9
+ ABNF grammar is taken directly from Arazzo Specification.
10
+ Copy of the Apache 2.0 license can be found in `LICENSE` file.
package/README.md ADDED
@@ -0,0 +1,290 @@
1
+ # @swaggerexpert/arazzo-runtime-expression
2
+
3
+ [![npmversion](https://img.shields.io/npm/v/%40swaggerexpert%2Farazzo-runtime-expression?style=flat-square&label=npm%20package&color=%234DC81F&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40swaggerexpert%2Farazzo-runtime-expression)](https://www.npmjs.com/package/@swaggerexpert/arazzo-runtime-expression)
4
+ [![npm](https://img.shields.io/npm/dm/@swaggerexpert/arazzo-runtime-expression)](https://www.npmjs.com/package/@swaggerexpert/arazzo-runtime-expression)
5
+ [![Test workflow](https://github.com/swaggerexpert/arazzo-runtime-expression/actions/workflows/test.yml/badge.svg)](https://github.com/swaggerexpert/arazzo-runtime-expression/actions)
6
+ [![Dependabot enabled](https://img.shields.io/badge/Dependabot-enabled-blue.svg)](https://dependabot.com/)
7
+ [![try on RunKit](https://img.shields.io/badge/try%20on-RunKit-brightgreen.svg?style=flat)](https://npm.runkit.com/@swaggerexpert/arazzo-runtime-expression)
8
+ [![Tidelift](https://tidelift.com/badges/package/npm/@swaggerexpert%2Farazzo-runtime-expression)](https://tidelift.com/subscription/pkg/npm-.swaggerexpert-arazzo-runtime-expression?utm_source=npm-swaggerexpert-arazzo-runtime-expression&utm_medium=referral&utm_campaign=readme)
9
+
10
+ [Arazzo Runtime Expressions](https://spec.openapis.org/arazzo/latest.html#runtime-expressions) allows values to be defined based on information that will be available within the HTTP message in an actual API call,
11
+ or within objects serialized from the Arazzo document such as [workflows](https://spec.openapis.org/arazzo/latest.html#workflow-object) or [steps](https://spec.openapis.org/arazzo/latest.html#step-object).
12
+
13
+ `@swaggerexpert/arazzo-runtime-expression` is a **parser**, **validator** and **extractor** for Arazzo Runtime Expressions.
14
+
15
+ It supports Runtime Expressions defined in following Arazzo specification versions:
16
+
17
+ - [Arazzo 1.0.0](https://spec.openapis.org/arazzo/v1.0.0.html)
18
+ - [Arazzo 1.0.1](https://spec.openapis.org/arazzo/v1.0.1.html)
19
+
20
+ <table>
21
+ <tr>
22
+ <td align="right" valign="middle">
23
+ <img src="https://cdn2.hubspot.net/hubfs/4008838/website/logos/logos_for_download/Tidelift_primary-shorthand-logo.png" alt="Tidelift" width="60" />
24
+ </td>
25
+ <td valign="middle">
26
+ <a href="https://tidelift.com/subscription/pkg/npm-.swaggerexpert-arazzo-runtime-expression?utm_source=npm-swaggerexpert-arazzo-runtime-expression&utm_medium=referral&utm_campaign=readme">
27
+ Get professionally supported @swaggerexpert/arazzo-runtime-expression with Tidelift Subscription.
28
+ </a>
29
+ </td>
30
+ </tr>
31
+ </table>
32
+
33
+ ## Table of Contents
34
+
35
+ - [Getting started](#getting-started)
36
+ - [Installation](#installation)
37
+ - [Usage](#usage)
38
+ - [Extraction](#extraction)
39
+ - [Parsing](#parsing)
40
+ - [Validation](#validation)
41
+ - [Grammar](#grammar)
42
+ - [More about Arazzo runtime expressions](#more-about-arazzo-runtime-expressions)
43
+ - [License](#license)
44
+
45
+
46
+ ## Getting started
47
+
48
+ ### Installation
49
+
50
+ You can install `@swaggerexpert/arazzo-runtime-expression` using `npm`:
51
+
52
+ ```sh
53
+ $ npm install @swaggerexpert/arazzo-runtime-expression
54
+ ```
55
+
56
+ ### Usage
57
+
58
+ `@swaggerexpert/arazzo-runtime-expression` currently supports **extraction**, **parsing** and **validation**.
59
+ Both parser and validator are based on a superset of [ABNF](https://www.rfc-editor.org/rfc/rfc5234) ([SABNF](https://cs.github.com/ldthomas/apg-js2/blob/master/SABNF.md))
60
+ and use [apg-lite](https://github.com/ldthomas/apg-lite) parser generator.
61
+
62
+ #### Extraction
63
+
64
+ Arazzo embeds Runtime Expressions into string values surrounded with `{}` curly braces.
65
+ To extract Runtime Expressions from this embedded form, use the **extract** function.
66
+ Extracted Runtime Expression can be used for further parsing of validation.
67
+
68
+ ```js
69
+ import { extract, test, parse } from '@swaggerexpert/arazzo-runtime-expression';
70
+
71
+ const expression = extract('{$request.header.accept}'); // => '$request.header.accept'
72
+
73
+ test(expression); // => true
74
+ parse(expression); // => { result, ast }
75
+ ```
76
+
77
+ #### Parsing
78
+
79
+ Parsing a Runtime Expression is as simple as importing the **parse** function and calling it.
80
+
81
+ ```js
82
+ import { parse } from '@swaggerexpert/arazzo-runtime-expression';
83
+
84
+ const parseResult = parse('$request.header.accept');
85
+ ```
86
+
87
+ **parseResult** variable has the following shape:
88
+
89
+ ```
90
+ {
91
+ result: {
92
+ success: true,
93
+ state: 101,
94
+ stateName: 'MATCH',
95
+ length: 22,
96
+ matched: 22,
97
+ maxMatched: 22,
98
+ maxTreeDepth: 13,
99
+ nodeHits: 152
100
+ },
101
+ ast: fnast {
102
+ callbacks: [
103
+ expression: [Function: expression],
104
+ 'parameter-name': [Function: parameterName],
105
+ source: [Function: source],
106
+ 'header-reference': [Function: headerReference],
107
+ 'query-reference': [Function: queryReference],
108
+ 'path-reference': [Function: pathReference],
109
+ 'body-reference': [Function: bodyReference],
110
+ 'json-pointer': [Function: jsonPointer],
111
+ 'reference-token': [Function: referenceToken],
112
+ name: [Function: name],
113
+ token: [Function: token]
114
+ ],
115
+ init: [Function (anonymous)],
116
+ ruleDefined: [Function (anonymous)],
117
+ udtDefined: [Function (anonymous)],
118
+ down: [Function (anonymous)],
119
+ up: [Function (anonymous)],
120
+ translate: [Function (anonymous)],
121
+ setLength: [Function (anonymous)],
122
+ getLength: [Function (anonymous)],
123
+ toXml: [Function (anonymous)]
124
+ }
125
+ }
126
+ ```
127
+
128
+ ###### Interpreting AST as list of entries
129
+
130
+ ```js
131
+ import { parse } from '@swaggerexpert/arazzo-runtime-expression';
132
+
133
+ const parseResult = parse('$request.header.accept');
134
+ const parts = [];
135
+
136
+ parseResult.ast.translate(parts);
137
+ ```
138
+
139
+ After running the above code, **parts** variable has the following shape:
140
+
141
+ ```js
142
+ [
143
+ [ 'expression', '$request.header.accept' ],
144
+ [ 'source', 'header.accept' ],
145
+ [ 'header-reference', 'header.accept' ],
146
+ [ 'token', 'accept' ],
147
+ ]
148
+ ```
149
+
150
+ ###### Interpreting AST as XML
151
+
152
+ ```js
153
+ import { parse } from '@swaggerexpert/arazzo-runtime-expression';
154
+
155
+ const parseResult = parse('$request.header.accept');
156
+ const xml = parseResult.ast.toXml();
157
+ ```
158
+
159
+ After running the above code, **xml** variable has the following content:
160
+
161
+ ```xml
162
+ <?xml version="1.0" encoding="utf-8"?>
163
+ <root nodes="4" characters="22">
164
+ <!-- input string -->
165
+ $request.header.accept
166
+ <node name="expression" index="0" length="22">
167
+ $request.header.accept
168
+ <node name="source" index="9" length="13">
169
+ header.accept
170
+ <node name="header-reference" index="9" length="13">
171
+ header.accept
172
+ <node name="token" index="16" length="6">
173
+ accept
174
+ </node><!-- name="token" -->
175
+ </node><!-- name="header-reference" -->
176
+ </node><!-- name="source" -->
177
+ </node><!-- name="expression" -->
178
+ </root>
179
+ ```
180
+
181
+ > NOTE: AST can also be traversed in classical way using [depth first traversal](https://www.tutorialspoint.com/data_structures_algorithms/depth_first_traversal.htm). For more information about this option please refer to [apg-js](https://github.com/ldthomas/apg-js) and [apg-js-examples](https://github.com/ldthomas/apg-js-examples).
182
+
183
+ #### Validation
184
+
185
+ Validating a Runtime Expression is as simple as importing the **test** function and calling it.
186
+
187
+ ```js
188
+ import { test } from '@swaggerexpert/arazzo-runtime-expression';
189
+
190
+ test('$request.header.accept'); // => true
191
+ test('nonsensical string'); // => false
192
+ ```
193
+
194
+ #### Grammar
195
+
196
+ New grammar instance can be created in following way:
197
+
198
+ ```js
199
+ import { Grammar } from '@swaggerexpert/arazzo-runtime-expression';
200
+
201
+ const grammar = new Grammar();
202
+ ```
203
+
204
+ To obtain original ABNF (SABNF) grammar as a string:
205
+
206
+ ```js
207
+ import { Grammar } from '@swaggerexpert/arazzo-runtime-expression';
208
+
209
+ const grammar = new Grammar();
210
+
211
+ grammar.toString();
212
+ // or
213
+ String(grammar);
214
+ ```
215
+
216
+ ## More about Arazzo runtime expressions
217
+
218
+ The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax
219
+
220
+ ```abnf
221
+ ; Arazzo runtime expression ABNF syntax
222
+ expression = ( "$url" / "$method" / "$statusCode" / "$request." source / "$response." source / "$inputs." name / "$outputs." name / "$steps." name / "$workflows." name / "$sourceDescriptions." name / "$components." name / "$components.parameters." parameter-name)
223
+ parameter-name = name ; Reuses 'name' rule for parameter names
224
+ source = ( header-reference / query-reference / path-reference / body-reference )
225
+ header-reference = "header." token
226
+ query-reference = "query." name
227
+ path-reference = "path." name
228
+ body-reference = "body" ["#" json-pointer ]
229
+
230
+ ; https://datatracker.ietf.org/doc/html/rfc6901#section-3
231
+ json-pointer = *( "/" reference-token )
232
+ reference-token = *( unescaped / escaped )
233
+ unescaped = %x00-2E / %x30-7D / %x7F-10FFFF
234
+ ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'
235
+ escaped = "~" ( "0" / "1" )
236
+ ; representing '~' and '/', respectively
237
+ name = *( CHAR )
238
+ token = 1*tchar
239
+ tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "."
240
+ / "^" /"_" / "`" / "|" / "~" / DIGIT / ALPHA
241
+
242
+ ; https://www.rfc-editor.org/rfc/rfc7159#section-7
243
+ CHAR = unescape /
244
+ escape (
245
+ %x22 / ; " quotation mark U+0022
246
+ %x5C / ; \ reverse solidus U+005C
247
+ %x2F / ; / solidus U+002F
248
+ %x62 / ; b backspace U+0008
249
+ %x66 / ; f form feed U+000C
250
+ %x6E / ; n line feed U+000A
251
+ %x72 / ; r carriage return U+000D
252
+ %x74 / ; t tab U+0009
253
+ %x75 4HEXDIG ) ; uXXXX U+XXXX
254
+ escape = %x5C ; \
255
+ unescape = %x20-21 / %x23-5B / %x5D-10FFFF
256
+
257
+ ; https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1
258
+ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
259
+ DIGIT = %x30-39 ; 0-9
260
+ ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
261
+ ```
262
+
263
+ The `name` identifier is case-sensitive, whereas `token` is not.
264
+
265
+ The table below provides examples of runtime expressions and examples of their use in a value:
266
+
267
+ #### Examples
268
+
269
+ Source Location | example expression | notes
270
+ ---|:---|:---|
271
+ HTTP Method | `$method` | The allowable values for the `$method` will be those for the HTTP operation.
272
+ Requested media type | `$request.header.accept` |
273
+ Request parameter | `$request.path.id` | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers.
274
+ Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body.
275
+ Request URL | `$url` |
276
+ Response value | `$response.body#/status` | In operations which return payloads, references may be made to portions of the response body or the entire body.
277
+ Response header | `$response.header.Server` | Single header values only are available
278
+ workflow input | `$inputs.username` or `$workflows.foo.inputs.username` | Single input values only are available
279
+ Step output value | `$steps.someStepId.outputs.pets` | In situations where the output named property return payloads, references may be made to portions of the response body (e.g., `$steps.someStepId.outputs.pets#/0/id`) or the entire body.
280
+ Workflow output value | `$outputs.bar` or `$workflows.foo.outputs.bar` | In situations where the output named property return payloads, references may be made to portions of the response body (e.g., `$workflows.foo.outputs.mappedResponse#/name`) or the entire body.
281
+ Components parameter | `$components.parameters.foo` | Accesses a foo parameter defined within the Components Object.
282
+
283
+ Runtime expressions preserve the type of the referenced value.
284
+ Expressions can be embedded into string values by surrounding the expression with `{}` curly braces.
285
+
286
+ ## License
287
+
288
+ `@swaggerexpert/arazzo-runtime-expression` is licensed under [Apache 2.0 license](https://github.com/swaggerexpert/arazzo-runtime-expression/blob/main/LICENSE).
289
+ `@swaggerexpert/arazzo-runtime-expression` comes with an explicit [NOTICE](https://github.com/swaggerexpert/arazzo-runtime-expression/blob/main/NOTICE) file
290
+ containing additional legal notices and information.
package/SECURITY.md ADDED
@@ -0,0 +1,15 @@
1
+ # Security Policy
2
+
3
+ If you believe you've found an exploitable security issue in @swaggerexpert/arazzo-runtime-expression, please don't create a public issue.
4
+
5
+ ## Supported Versions
6
+
7
+ | Version | Supported |
8
+ |---------|--------------------|
9
+ | ^1.0.0 | :white_check_mark: |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ To report a vulnerability please send an email with the details to contact@swaggerexpert.com.
14
+
15
+ I'll acknowledge receipt of your report ASAP, and set expectations on how I plan to handle it.