Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-runtime-expression

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-runtime-expression - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

src/extract.js

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc