@swagger-api/apidom-parser-adapter-openapi-json-3-1 0.68.1

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.
package/es/adapter.js ADDED
@@ -0,0 +1,23 @@
1
+ import { propOr, omit } from 'ramda';
2
+ import { isNotUndefined } from 'ramda-adjunct';
3
+ import { createNamespace } from '@swagger-api/apidom-core';
4
+ import { parse as parseJSON, detect as detectJSON } from '@swagger-api/apidom-parser-adapter-json';
5
+ import openApiNamespace, { OpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-3-1';
6
+ export { default as mediaTypes } from "./media-types.js";
7
+ export const detectionRegExp = /"openapi"\s*:\s*"(?<version_json>3\.1\.(?:[1-9]\d*|0))"/;
8
+ export const detect = async source => detectionRegExp.test(source) && (await detectJSON(source));
9
+ export const parse = async (source, options = {}) => {
10
+ const refractorOpts = propOr({}, 'refractorOpts', options);
11
+ const parserOpts = omit(['refractorOpts'], options);
12
+ const parseResultElement = await parseJSON(source, parserOpts);
13
+ const {
14
+ result
15
+ } = parseResultElement;
16
+ if (isNotUndefined(result)) {
17
+ const openApiElement = OpenApi3_1Element.refract(result, refractorOpts);
18
+ openApiElement.classes.push('result');
19
+ parseResultElement.replaceResult(openApiElement);
20
+ }
21
+ return parseResultElement;
22
+ };
23
+ export const namespace = createNamespace(openApiNamespace);
@@ -0,0 +1,3 @@
1
+ import { mediaTypes, OpenAPIMediaTypes } from '@swagger-api/apidom-ns-openapi-3-1';
2
+ const jsonMediaTypes = new OpenAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('json'));
3
+ export default jsonMediaTypes;
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@swagger-api/apidom-parser-adapter-openapi-json-3-1",
3
+ "version": "0.68.1",
4
+ "description": "Parser adapter for parsing JSON documents into OpenAPI 3.1.x namespace.",
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "registry": "https://registry.npmjs.org"
8
+ },
9
+ "type": "module",
10
+ "sideEffects": false,
11
+ "unpkg": "./dist/apidom-parser-apdater-openapi-json-3-1.browser.min.js",
12
+ "main": "./cjs/adapter.cjs",
13
+ "exports": {
14
+ "types": "./types/dist.d.ts",
15
+ "import": "./es/adapter.js",
16
+ "require": "./cjs/adapter.cjs"
17
+ },
18
+ "types": "./types/dist.d.ts",
19
+ "scripts": {
20
+ "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
21
+ "build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --root-mode 'upward'",
22
+ "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
23
+ "build:umd:browser": "cross-env BABEL_ENV=browser BROWSERSLIST_ENV=production webpack --config config/webpack/browser.config.js --progress",
24
+ "lint": "eslint ./",
25
+ "lint:fix": "eslint ./ --fix",
26
+ "clean": "rimraf ./es ./cjs ./dist ./types",
27
+ "typescript:check-types": "tsc --noEmit",
28
+ "typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
29
+ "test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha",
30
+ "perf": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/index.cjs",
31
+ "perf:lexical-analysis": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/lexical-analysis.cjs",
32
+ "perf:syntactic-analysis": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/syntactic-analysis.cjs",
33
+ "perf:refract": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/refract.cjs",
34
+ "perf:parse": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/parse.cjs",
35
+ "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
36
+ "postpack": "rimraf NOTICE LICENSES"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/swagger-api/apidom.git"
41
+ },
42
+ "author": "Vladimir Gorej",
43
+ "license": "Apache-2.0",
44
+ "dependencies": {
45
+ "@babel/runtime-corejs3": "^7.20.7",
46
+ "@swagger-api/apidom-core": "^0.68.1",
47
+ "@swagger-api/apidom-ns-openapi-3-1": "^0.68.1",
48
+ "@swagger-api/apidom-parser-adapter-json": "^0.68.1",
49
+ "@types/ramda": "=0.28.23",
50
+ "ramda": "=0.28.0",
51
+ "ramda-adjunct": "=3.4.0"
52
+ },
53
+ "files": [
54
+ "cjs/",
55
+ "dist/",
56
+ "es/",
57
+ "types/dist.d.ts",
58
+ "LICENSES",
59
+ "NOTICE",
60
+ "README.md",
61
+ "CHANGELOG.md"
62
+ ],
63
+ "gitHead": "d2bc706671f1b9a593b8f0c5bca8c501ad0e4cff"
64
+ }
@@ -0,0 +1,12 @@
1
+ import * as _swagger_api_apidom_core from '@swagger-api/apidom-core';
2
+ import { ParseResultElement } from '@swagger-api/apidom-core';
3
+ import { OpenAPIMediaTypes } from '@swagger-api/apidom-ns-openapi-3-1';
4
+
5
+ declare const jsonMediaTypes: OpenAPIMediaTypes;
6
+
7
+ declare const detectionRegExp: RegExp;
8
+ declare const detect: (source: string) => Promise<boolean>;
9
+ declare const parse: (source: string, options?: Record<string, unknown>) => Promise<ParseResultElement>;
10
+ declare const namespace: _swagger_api_apidom_core.Namespace;
11
+
12
+ export { detect, detectionRegExp, jsonMediaTypes as mediaTypes, namespace, parse };