@swagger-api/apidom-parser-adapter-openapi-yaml-2 0.81.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.
package/es/adapter.mjs 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 parseYAML, detect as detectYAML } from '@swagger-api/apidom-parser-adapter-yaml-1-2';
5
+ import openApiNamespace, { SwaggerElement } from '@swagger-api/apidom-ns-openapi-2';
6
+ export { default as mediaTypes } from "./media-types.mjs";
7
+ export const detectionRegExp = /(?<YAML>^(["']?)swagger\2\s*:\s*(["'])(?<version_yaml>2\.0)\3(?:\s+|$))|(?<JSON>"swagger"\s*:\s*"(?<version_json>2\.0)")/m;
8
+ export const detect = async source => detectionRegExp.test(source) && (await detectYAML(source));
9
+ export const parse = async (source, options = {}) => {
10
+ const refractorOpts = propOr({}, 'refractorOpts', options);
11
+ const parserOpts = omit(['refractorOpts'], options);
12
+ const parseResultElement = await parseYAML(source, parserOpts);
13
+ const {
14
+ result
15
+ } = parseResultElement;
16
+ if (isNotUndefined(result)) {
17
+ const swaggerElement = SwaggerElement.refract(result, refractorOpts);
18
+ swaggerElement.classes.push('result');
19
+ parseResultElement.replaceResult(swaggerElement);
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-2';
2
+ const yamlMediaTypes = new OpenAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('yaml'));
3
+ export default yamlMediaTypes;
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@swagger-api/apidom-parser-adapter-openapi-yaml-2",
3
+ "version": "0.81.0",
4
+ "description": "Parser adapter for parsing YAML documents into OpenAPI 2.0 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-yaml-2.browser.min.js",
12
+ "main": "./cjs/adapter.cjs",
13
+ "exports": {
14
+ "types": "./types/dist.d.ts",
15
+ "import": "./es/adapter.mjs",
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' --out-file-extension '.mjs' --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 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
+ "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
31
+ "postpack": "rimraf NOTICE LICENSES"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/swagger-api/apidom.git"
36
+ },
37
+ "author": "Vladimir Gorej",
38
+ "license": "Apache-2.0",
39
+ "dependencies": {
40
+ "@babel/runtime-corejs3": "^7.20.7",
41
+ "@swagger-api/apidom-core": "^0.81.0",
42
+ "@swagger-api/apidom-ns-openapi-2": "^0.81.0",
43
+ "@swagger-api/apidom-parser-adapter-yaml-1-2": "^0.81.0",
44
+ "@types/ramda": "~0.29.6",
45
+ "ramda": "~0.29.0",
46
+ "ramda-adjunct": "^4.0.0"
47
+ },
48
+ "files": [
49
+ "cjs/",
50
+ "dist/",
51
+ "es/",
52
+ "types/dist.d.ts",
53
+ "LICENSES",
54
+ "NOTICE",
55
+ "README.md",
56
+ "CHANGELOG.md"
57
+ ],
58
+ "gitHead": "06960c4ddf3aaaaf394b4ffcb4e42201f9bcbad6"
59
+ }
@@ -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-2';
4
+
5
+ declare const yamlMediaTypes: 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, yamlMediaTypes as mediaTypes, namespace, parse };