openapi-runtime-expression
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "openapi-runtime-expression", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "OpenAPI Runtime expressions parser and validator.", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -5,3 +5,3 @@ # openapi-runtime-expression | ||
This mechanism is used by [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#linkObject) and [Callback Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callbackObject) | ||
of [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification); | ||
of [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification). | ||
@@ -22,2 +22,3 @@ `openapi-runtime-expression` is a **parser** and **validator** for OpenAPI Runtime Expressions. It supports | ||
- [Usage](#usage) | ||
- [Extraction](#extraction) | ||
- [Parsing](#parsing) | ||
@@ -50,6 +51,21 @@ - [Validation](#validation) | ||
`openapi-runtime-expression` currently supports **parsing** and **validation**. | ||
`openapi-runtime-expression` currently supports **extraction**, **parsing** and **validation**. | ||
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)) | ||
and use [apg-js](https://github.com/ldthomas/apg-js) parser generator. | ||
#### Extraction | ||
OpenAPI embeds Runtime Expressions into string values surrounded with `{}` curly braces. | ||
To extract Runtime Expressions from this embedded form, use the **extract** function. | ||
Extracted Runtime Expression can be used for further parsing of validation. | ||
```js | ||
import { extract, test, parse } from 'openapi-runtime-expression'; | ||
const expression = extract('{$request.header.accept}'); // => '$request.header.accept' | ||
test(expression); // => true | ||
parse(expression); // => { result, ast } | ||
``` | ||
#### Parsing | ||
@@ -56,0 +72,0 @@ |
export { default as Grammar } from './runtime-expression.cjs'; | ||
export { default as extract } from './extract.js'; | ||
export { default as test } from './test.js'; | ||
export { default as parse } from './parse/index.js'; |
@@ -7,3 +7,3 @@ import ApgExp from 'apg-js/src/apg-exp/apg-exp.js'; | ||
const test = (str) => { | ||
const test = (str, { strict = false } = {}) => { | ||
if (typeof str !== 'string') { | ||
@@ -13,3 +13,3 @@ return false; | ||
const apgExp = new ApgExp(grammar); | ||
const apgExp = new ApgExp(grammar, 'y'); | ||
return apgExp.test(str); | ||
@@ -16,0 +16,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47294
22
409
266