@speclynx/apidom-parser-adapter-openapi-json-2 4.0.3 → 4.0.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-openapi-json-2",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Parser adapter for parsing JSON documents into OpenAPI 2.0 namespace.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apidom",
|
|
@@ -56,15 +56,16 @@
|
|
|
56
56
|
"license": "Apache-2.0",
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
59
|
-
"@speclynx/apidom-core": "4.0.
|
|
60
|
-
"@speclynx/apidom-datamodel": "4.0.
|
|
61
|
-
"@speclynx/apidom-ns-openapi-2": "4.0.
|
|
62
|
-
"@speclynx/apidom-parser-adapter-json": "4.0.
|
|
59
|
+
"@speclynx/apidom-core": "4.0.4",
|
|
60
|
+
"@speclynx/apidom-datamodel": "4.0.4",
|
|
61
|
+
"@speclynx/apidom-ns-openapi-2": "4.0.4",
|
|
62
|
+
"@speclynx/apidom-parser-adapter-json": "4.0.4",
|
|
63
63
|
"ramda": "~0.32.0",
|
|
64
64
|
"ramda-adjunct": "^6.0.0"
|
|
65
65
|
},
|
|
66
66
|
"files": [
|
|
67
|
-
"src
|
|
67
|
+
"src/**/*.mjs",
|
|
68
|
+
"src/**/*.cjs",
|
|
68
69
|
"dist/",
|
|
69
70
|
"types/apidom-parser-adapter-openapi-json-2.d.ts",
|
|
70
71
|
"LICENSES",
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"README.md",
|
|
73
74
|
"CHANGELOG.md"
|
|
74
75
|
],
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "a06f6ef3d37ad5bf860cbbf4b442bfbe3a522cc2"
|
|
76
77
|
}
|
package/src/adapter.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { propOr, omit } from 'ramda';
|
|
2
|
-
import { isNotUndefined } from 'ramda-adjunct';
|
|
3
|
-
import { ParseResultElement, Namespace } from '@speclynx/apidom-datamodel';
|
|
4
|
-
import {
|
|
5
|
-
parse as parseJSON,
|
|
6
|
-
detect as detectJSON,
|
|
7
|
-
type ParseDetectOptions,
|
|
8
|
-
type ParseOptions as ParseOptionsJSON,
|
|
9
|
-
} from '@speclynx/apidom-parser-adapter-json';
|
|
10
|
-
import openApiNamespace, { refractSwagger } from '@speclynx/apidom-ns-openapi-2';
|
|
11
|
-
|
|
12
|
-
export { default as mediaTypes } from './media-types.ts';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export const detectionRegExp = /"swagger"\s*:\s*"(?<version_json>2\.0)"/;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export const detect: typeof detectJSON = async (
|
|
23
|
-
source: string,
|
|
24
|
-
options: ParseDetectOptions = {},
|
|
25
|
-
): Promise<boolean> => detectionRegExp.test(source) && (await detectJSON(source, options));
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
export interface ParseOptions extends ParseOptionsJSON {
|
|
31
|
-
refractorOpts?: Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export const parse: typeof parseJSON = async (
|
|
38
|
-
source: string,
|
|
39
|
-
options: ParseOptions = {},
|
|
40
|
-
): Promise<ParseResultElement> => {
|
|
41
|
-
const refractorOpts: Record<string, unknown> = propOr({}, 'refractorOpts', options);
|
|
42
|
-
const parserOpts = omit(['refractorOpts'], options);
|
|
43
|
-
const parseResultElement = await parseJSON(source, parserOpts);
|
|
44
|
-
const { result } = parseResultElement;
|
|
45
|
-
|
|
46
|
-
if (isNotUndefined(result)) {
|
|
47
|
-
const swaggerElement = refractSwagger(result, { consume: true, ...refractorOpts });
|
|
48
|
-
swaggerElement.classes.push('result');
|
|
49
|
-
parseResultElement.replaceResult(swaggerElement);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return parseResultElement;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export const namespace = new Namespace().use(openApiNamespace);
|
package/src/media-types.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { mediaTypes, OpenAPIMediaTypes } from '@speclynx/apidom-ns-openapi-2';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
const jsonMediaTypes = new OpenAPIMediaTypes(
|
|
7
|
-
...mediaTypes.filterByFormat('generic'),
|
|
8
|
-
...mediaTypes.filterByFormat('json'),
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export default jsonMediaTypes;
|