@speclynx/apidom-ns-openapi-2 4.0.3 → 4.0.5
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/CHANGELOG.md +10 -0
- package/dist/apidom-ns-openapi-2.browser.js +35 -11
- package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
- package/package.json +9 -8
- package/src/elements/Contact.ts +0 -42
- package/src/elements/Definitions.ts +0 -13
- package/src/elements/Example.ts +0 -13
- package/src/elements/ExternalDocumentation.ts +0 -34
- package/src/elements/Header.ts +0 -261
- package/src/elements/Headers.ts +0 -13
- package/src/elements/Info.ts +0 -70
- package/src/elements/Items.ts +0 -264
- package/src/elements/License.ts +0 -34
- package/src/elements/Operation.ts +0 -106
- package/src/elements/Parameter.ts +0 -326
- package/src/elements/ParametersDefinitions.ts +0 -13
- package/src/elements/PathItem.ts +0 -93
- package/src/elements/Paths.ts +0 -13
- package/src/elements/Reference.ts +0 -27
- package/src/elements/Response.ts +0 -54
- package/src/elements/Responses.ts +0 -24
- package/src/elements/ResponsesDefinitions.ts +0 -13
- package/src/elements/Schema.ts +0 -204
- package/src/elements/Scopes.ts +0 -13
- package/src/elements/SecurityDefinitions.ts +0 -13
- package/src/elements/SecurityRequirement.ts +0 -13
- package/src/elements/SecurityScheme.ts +0 -83
- package/src/elements/Swagger.ts +0 -149
- package/src/elements/SwaggerVersion.ts +0 -15
- package/src/elements/Tag.ts +0 -44
- package/src/elements/Xml.ts +0 -59
- package/src/elements/nces/OperationConsumes.ts +0 -15
- package/src/elements/nces/OperationParameters.ts +0 -16
- package/src/elements/nces/OperationProduces.ts +0 -15
- package/src/elements/nces/OperationSchemes.ts +0 -15
- package/src/elements/nces/OperationSecurity.ts +0 -16
- package/src/elements/nces/OperationTags.ts +0 -16
- package/src/elements/nces/PathItemParameters.ts +0 -16
- package/src/elements/nces/SwaggerConsumes.ts +0 -15
- package/src/elements/nces/SwaggerProduces.ts +0 -15
- package/src/elements/nces/SwaggerSchemes.ts +0 -15
- package/src/elements/nces/SwaggerSecurity.ts +0 -16
- package/src/elements/nces/SwaggerTags.ts +0 -15
- package/src/index.ts +0 -368
- package/src/media-types.ts +0 -42
- package/src/namespace.ts +0 -70
- package/src/predicates.ts +0 -194
- package/src/refractor/index.ts +0 -330
- package/src/refractor/inspect.ts +0 -181
- package/src/refractor/plugins/replace-empty-element.ts +0 -389
- package/src/refractor/predicates.ts +0 -29
- package/src/refractor/specification.ts +0 -444
- package/src/refractor/toolbox.ts +0 -24
- package/src/refractor/visitors/FallbackVisitor.ts +0 -25
- package/src/refractor/visitors/SpecificationExtensionVisitor.ts +0 -22
- package/src/refractor/visitors/SpecificationVisitor.ts +0 -83
- package/src/refractor/visitors/Visitor.ts +0 -47
- package/src/refractor/visitors/generics/AlternatingVisitor.ts +0 -45
- package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +0 -109
- package/src/refractor/visitors/generics/MapVisitor.ts +0 -25
- package/src/refractor/visitors/generics/MixedFieldsVisitor.ts +0 -77
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +0 -99
- package/src/refractor/visitors/open-api-2/BasePathVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/HostVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-2/ProducesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/SchemesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/SecurityVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/TagsVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-2/bases.ts +0 -82
- package/src/refractor/visitors/open-api-2/contact/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/definitions/index.ts +0 -48
- package/src/refractor/visitors/open-api-2/example/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/external-documentation/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/header/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/headers/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/index.ts +0 -28
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.ts +0 -21
- package/src/refractor/visitors/open-api-2/info/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/items/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/license/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.ts +0 -44
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.ts +0 -34
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.ts +0 -29
- package/src/refractor/visitors/open-api-2/operation/index.ts +0 -24
- package/src/refractor/visitors/open-api-2/parameter/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.ts +0 -24
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.ts +0 -44
- package/src/refractor/visitors/open-api-2/path-item/index.ts +0 -48
- package/src/refractor/visitors/open-api-2/paths/index.ts +0 -48
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.ts +0 -20
- package/src/refractor/visitors/open-api-2/reference/index.ts +0 -38
- package/src/refractor/visitors/open-api-2/response/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.ts +0 -36
- package/src/refractor/visitors/open-api-2/responses/index.ts +0 -64
- package/src/refractor/visitors/open-api-2/responses-definitions/index.ts +0 -24
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.ts +0 -35
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.ts +0 -38
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.ts +0 -35
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.ts +0 -37
- package/src/refractor/visitors/open-api-2/schema/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/scopes/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/security-definitions/index.ts +0 -24
- package/src/refractor/visitors/open-api-2/security-requirement/index.ts +0 -24
- package/src/refractor/visitors/open-api-2/security-scheme/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/tag/index.ts +0 -27
- package/src/refractor/visitors/open-api-2/xml/index.ts +0 -27
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ifElse, always } from 'ramda';
|
|
2
|
-
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
-
import { Element } from '@speclynx/apidom-datamodel';
|
|
4
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
5
|
-
|
|
6
|
-
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export type Alternator = { predicate: (element: unknown) => boolean; specPath: string[] };
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export interface AlternatingVisitorOptions extends SpecificationVisitorOptions {
|
|
17
|
-
readonly alternator?: Alternator[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
class AlternatingVisitor extends SpecificationVisitor {
|
|
24
|
-
protected alternator: Alternator[];
|
|
25
|
-
|
|
26
|
-
constructor({ alternator, ...rest }: AlternatingVisitorOptions) {
|
|
27
|
-
super({ ...rest });
|
|
28
|
-
this.alternator = alternator || [];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
enter(path: Path<Element>) {
|
|
32
|
-
const element = path.node;
|
|
33
|
-
const functions = this.alternator.map(
|
|
34
|
-
({ predicate, specPath }: { predicate: (element: unknown) => boolean; specPath: string[] }) =>
|
|
35
|
-
ifElse(predicate, always(specPath), stubUndefined),
|
|
36
|
-
);
|
|
37
|
-
const specPath = dispatch(functions)(element);
|
|
38
|
-
|
|
39
|
-
this.element = this.toRefractedElement(specPath, element);
|
|
40
|
-
|
|
41
|
-
path.stop();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default AlternatingVisitor;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isStringElement,
|
|
3
|
-
MemberElement,
|
|
4
|
-
Element,
|
|
5
|
-
ObjectElement,
|
|
6
|
-
cloneDeep,
|
|
7
|
-
} from '@speclynx/apidom-datamodel';
|
|
8
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
9
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
10
|
-
|
|
11
|
-
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
12
|
-
import { isSwaggerExtension } from '../../predicates.ts';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export type SpecPath<T = string[]> = (element: unknown) => T;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export interface FixedFieldsVisitorOptions extends SpecificationVisitorOptions {
|
|
23
|
-
readonly specPath: SpecPath;
|
|
24
|
-
readonly ignoredFields?: string[];
|
|
25
|
-
readonly canSupportSpecificationExtensions?: boolean;
|
|
26
|
-
readonly specificationExtensionPredicate?: typeof isSwaggerExtension;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
class FixedFieldsVisitor extends SpecificationVisitor {
|
|
33
|
-
protected specPath: SpecPath;
|
|
34
|
-
|
|
35
|
-
protected ignoredFields: string[];
|
|
36
|
-
|
|
37
|
-
protected canSupportSpecificationExtensions: boolean = true;
|
|
38
|
-
|
|
39
|
-
protected specificationExtensionPredicate = isSwaggerExtension;
|
|
40
|
-
|
|
41
|
-
constructor({
|
|
42
|
-
specPath,
|
|
43
|
-
ignoredFields,
|
|
44
|
-
canSupportSpecificationExtensions,
|
|
45
|
-
specificationExtensionPredicate,
|
|
46
|
-
...rest
|
|
47
|
-
}: FixedFieldsVisitorOptions) {
|
|
48
|
-
super({ ...rest });
|
|
49
|
-
this.specPath = specPath;
|
|
50
|
-
this.ignoredFields = ignoredFields || [];
|
|
51
|
-
|
|
52
|
-
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
53
|
-
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (typeof specificationExtensionPredicate === 'function') {
|
|
57
|
-
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
ObjectElement(path: Path<ObjectElement>) {
|
|
62
|
-
const objectElement = path.node;
|
|
63
|
-
const specPath = this.specPath(objectElement);
|
|
64
|
-
const fields = this.retrieveFixedFields(specPath);
|
|
65
|
-
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
objectElement.forEach((value: Element, key: Element, memberElement: MemberElement) => {
|
|
68
|
-
const keyValue = toValue(key) as string;
|
|
69
|
-
if (
|
|
70
|
-
isStringElement(key) &&
|
|
71
|
-
fields.includes(keyValue) &&
|
|
72
|
-
!this.ignoredFields.includes(keyValue)
|
|
73
|
-
) {
|
|
74
|
-
const fixedFieldElement = this.toRefractedElement(
|
|
75
|
-
[...specPath, 'fixedFields', keyValue],
|
|
76
|
-
value,
|
|
77
|
-
);
|
|
78
|
-
const newMemberElement = new MemberElement(
|
|
79
|
-
this.consume ? key : cloneDeep(key),
|
|
80
|
-
fixedFieldElement,
|
|
81
|
-
);
|
|
82
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
83
|
-
(this.element.content as Element[]).push(newMemberElement);
|
|
84
|
-
// consume: release processed generic subtree
|
|
85
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen)
|
|
86
|
-
memberElement.value = undefined;
|
|
87
|
-
} else if (
|
|
88
|
-
this.canSupportSpecificationExtensions &&
|
|
89
|
-
this.specificationExtensionPredicate(memberElement)
|
|
90
|
-
) {
|
|
91
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
92
|
-
(this.element.content as Element[]).push(extensionElement);
|
|
93
|
-
// consume: release processed generic subtree
|
|
94
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen)
|
|
95
|
-
memberElement.value = undefined;
|
|
96
|
-
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
97
|
-
(this.element.content as Element[]).push(
|
|
98
|
-
this.consume ? memberElement : cloneDeep(memberElement),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
104
|
-
|
|
105
|
-
path.stop();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export default FixedFieldsVisitor;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { isNonEmptyString } from 'ramda-adjunct';
|
|
2
|
-
|
|
3
|
-
import PatternedFieldsVisitor, {
|
|
4
|
-
PatternedFieldsVisitorOptions,
|
|
5
|
-
SpecPath,
|
|
6
|
-
} from './PatternedFieldsVisitor.ts';
|
|
7
|
-
|
|
8
|
-
export type { SpecPath };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export interface MapVisitorOptions extends PatternedFieldsVisitorOptions {}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
class MapVisitor extends PatternedFieldsVisitor {
|
|
19
|
-
constructor(options: MapVisitorOptions) {
|
|
20
|
-
super(options);
|
|
21
|
-
this.fieldPatternPredicate = isNonEmptyString;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default MapVisitor;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Mixin } from 'ts-mixer';
|
|
2
|
-
import { difference } from 'ramda';
|
|
3
|
-
import { ObjectElement, MemberElement, Element } from '@speclynx/apidom-datamodel';
|
|
4
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
5
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
6
|
-
|
|
7
|
-
import FixedFieldsVisitor, { SpecPath } from './FixedFieldsVisitor.ts';
|
|
8
|
-
import PatternedFieldsVisitor, { PatternedFieldsVisitorOptions } from './PatternedFieldsVisitor.ts';
|
|
9
|
-
|
|
10
|
-
export type { SpecPath };
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export interface MixedFieldsVisitorOptions extends PatternedFieldsVisitorOptions {
|
|
16
|
-
readonly specPathFixedFields: SpecPath;
|
|
17
|
-
readonly specPathPatternedFields: SpecPath;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Base class for MixedFieldsVisitor combining FixedFieldsVisitor and PatternedFieldsVisitor.
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export const MixedFieldsVisitorBase = Mixin(FixedFieldsVisitor, PatternedFieldsVisitor);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
class MixedFieldsVisitor extends MixedFieldsVisitorBase {
|
|
30
|
-
protected readonly specPathFixedFields: SpecPath;
|
|
31
|
-
|
|
32
|
-
protected readonly specPathPatternedFields: SpecPath;
|
|
33
|
-
|
|
34
|
-
constructor({
|
|
35
|
-
specPathFixedFields,
|
|
36
|
-
specPathPatternedFields,
|
|
37
|
-
...rest
|
|
38
|
-
}: MixedFieldsVisitorOptions) {
|
|
39
|
-
super({ ...rest });
|
|
40
|
-
this.specPathFixedFields = specPathFixedFields;
|
|
41
|
-
this.specPathPatternedFields = specPathPatternedFields;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
ObjectElement(path: Path<ObjectElement>) {
|
|
45
|
-
const objectElement = path.node;
|
|
46
|
-
const { specPath, ignoredFields } = this;
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
this.specPath = this.specPathFixedFields;
|
|
50
|
-
const fixedFields = this.retrieveFixedFields(this.specPath(objectElement));
|
|
51
|
-
// let FixedFieldsVisitor only process fixed fields and leave rest to PatternedFieldsVisitor
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
this.ignoredFields = [...ignoredFields, ...difference(objectElement.keys(), fixedFields)];
|
|
54
|
-
FixedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
55
|
-
|
|
56
|
-
this.specPath = this.specPathPatternedFields;
|
|
57
|
-
this.ignoredFields = fixedFields;
|
|
58
|
-
PatternedFieldsVisitor.prototype.ObjectElement.call(this, path);
|
|
59
|
-
|
|
60
|
-
// reorder this.element members by original objectElement keys
|
|
61
|
-
const objectElementKeys = objectElement.keys() as string[];
|
|
62
|
-
(this.element.content as Element[]).sort((a: unknown, b: unknown) => {
|
|
63
|
-
return (
|
|
64
|
-
objectElementKeys.indexOf(toValue((a as MemberElement).key) as string) -
|
|
65
|
-
objectElementKeys.indexOf(toValue((b as MemberElement).key) as string)
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
} catch (e) {
|
|
69
|
-
this.specPath = specPath;
|
|
70
|
-
throw e;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
path.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default MixedFieldsVisitor;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { F as stubFalse } from 'ramda';
|
|
2
|
-
import { ObjectElement, Element, MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
4
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
5
|
-
|
|
6
|
-
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
7
|
-
import type { SpecPath } from './FixedFieldsVisitor.ts';
|
|
8
|
-
import { isSwaggerExtension } from '../../predicates.ts';
|
|
9
|
-
|
|
10
|
-
export type { SpecPath };
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export interface PatternedFieldsVisitorOptions extends SpecificationVisitorOptions {
|
|
16
|
-
readonly specPath: SpecPath;
|
|
17
|
-
readonly ignoredFields?: string[];
|
|
18
|
-
readonly fieldPatternPredicate?: (...args: unknown[]) => boolean;
|
|
19
|
-
readonly canSupportSpecificationExtensions?: boolean;
|
|
20
|
-
readonly specificationExtensionPredicate?: typeof isSwaggerExtension;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
class PatternedFieldsVisitor extends SpecificationVisitor {
|
|
27
|
-
protected specPath: SpecPath;
|
|
28
|
-
|
|
29
|
-
protected ignoredFields: string[];
|
|
30
|
-
|
|
31
|
-
protected fieldPatternPredicate: (value: unknown) => boolean = stubFalse;
|
|
32
|
-
|
|
33
|
-
protected canSupportSpecificationExtensions: boolean = false;
|
|
34
|
-
|
|
35
|
-
protected specificationExtensionPredicate = isSwaggerExtension;
|
|
36
|
-
|
|
37
|
-
constructor({
|
|
38
|
-
specPath,
|
|
39
|
-
ignoredFields,
|
|
40
|
-
fieldPatternPredicate,
|
|
41
|
-
canSupportSpecificationExtensions,
|
|
42
|
-
specificationExtensionPredicate,
|
|
43
|
-
...rest
|
|
44
|
-
}: PatternedFieldsVisitorOptions) {
|
|
45
|
-
super({ ...rest });
|
|
46
|
-
this.specPath = specPath;
|
|
47
|
-
this.ignoredFields = ignoredFields || [];
|
|
48
|
-
|
|
49
|
-
if (typeof fieldPatternPredicate === 'function') {
|
|
50
|
-
this.fieldPatternPredicate = fieldPatternPredicate;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
54
|
-
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (typeof specificationExtensionPredicate === 'function') {
|
|
58
|
-
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
ObjectElement(path: Path<ObjectElement>) {
|
|
63
|
-
const objectElement = path.node;
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
objectElement.forEach((value: Element, key: Element, memberElement: MemberElement) => {
|
|
66
|
-
const keyValue = toValue(key) as string;
|
|
67
|
-
if (
|
|
68
|
-
this.canSupportSpecificationExtensions &&
|
|
69
|
-
this.specificationExtensionPredicate(memberElement)
|
|
70
|
-
) {
|
|
71
|
-
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
72
|
-
(this.element.content as Element[]).push(extensionElement);
|
|
73
|
-
} else if (!this.ignoredFields.includes(keyValue) && this.fieldPatternPredicate(keyValue)) {
|
|
74
|
-
const specPath = this.specPath(value);
|
|
75
|
-
const patternedFieldElement = this.toRefractedElement(specPath, value);
|
|
76
|
-
const newMemberElement = new MemberElement(
|
|
77
|
-
this.consume ? key : cloneDeep(key),
|
|
78
|
-
patternedFieldElement,
|
|
79
|
-
);
|
|
80
|
-
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
81
|
-
newMemberElement.classes.push('patterned-field');
|
|
82
|
-
(this.element.content as Element[]).push(newMemberElement);
|
|
83
|
-
// consume: release processed generic subtree
|
|
84
|
-
if (this.consume && this.consumeSafe && !memberElement.isFrozen)
|
|
85
|
-
memberElement.value = undefined;
|
|
86
|
-
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
87
|
-
(this.element.content as Element[]).push(
|
|
88
|
-
this.consume ? memberElement : cloneDeep(memberElement),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
this.copyMetaAndAttributes(objectElement, this.element);
|
|
94
|
-
|
|
95
|
-
path.stop();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default PatternedFieldsVisitor;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { StringElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
-
|
|
6
|
-
export type { FallbackVisitorOptions as BasePathVisitorOptions };
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
class BasePathVisitor extends FallbackVisitor {
|
|
12
|
-
declare public readonly element: StringElement;
|
|
13
|
-
|
|
14
|
-
StringElement(path: Path<StringElement>) {
|
|
15
|
-
super.enter(path);
|
|
16
|
-
this.element.classes.push('swagger-base-path');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default BasePathVisitor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import SwaggerConsumesElement from '../../../elements/nces/SwaggerConsumes.ts';
|
|
5
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
6
|
-
|
|
7
|
-
export type { FallbackVisitorOptions as ConsumesVisitorOptions };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class ConsumesVisitor extends FallbackVisitor {
|
|
13
|
-
declare public element: SwaggerConsumesElement;
|
|
14
|
-
|
|
15
|
-
constructor(options: FallbackVisitorOptions) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.element = new SwaggerConsumesElement();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ArrayElement(path: Path<ArrayElement>) {
|
|
21
|
-
const arrayElement = path.node;
|
|
22
|
-
|
|
23
|
-
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
24
|
-
|
|
25
|
-
path.stop();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default ConsumesVisitor;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { StringElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
-
|
|
6
|
-
export type { FallbackVisitorOptions as HostVisitorOptions };
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
class HostVisitor extends FallbackVisitor {
|
|
12
|
-
declare public readonly element: StringElement;
|
|
13
|
-
|
|
14
|
-
StringElement(path: Path<StringElement>) {
|
|
15
|
-
super.enter(path);
|
|
16
|
-
this.element.classes.push('swagger-host');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default HostVisitor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import SwaggerProducesElement from '../../../elements/nces/SwaggerProduces.ts';
|
|
5
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
6
|
-
|
|
7
|
-
export type { FallbackVisitorOptions as ProducesVisitorOptions };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class ProducesVisitor extends FallbackVisitor {
|
|
13
|
-
declare public element: SwaggerProducesElement;
|
|
14
|
-
|
|
15
|
-
constructor(options: FallbackVisitorOptions) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.element = new SwaggerProducesElement();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ArrayElement(path: Path<ArrayElement>) {
|
|
21
|
-
const arrayElement = path.node;
|
|
22
|
-
|
|
23
|
-
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
24
|
-
|
|
25
|
-
path.stop();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default ProducesVisitor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import SwaggerSchemesElement from '../../../elements/nces/SwaggerSchemes.ts';
|
|
5
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
6
|
-
|
|
7
|
-
export type { FallbackVisitorOptions as SchemesVisitorOptions };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class SchemesVisitor extends FallbackVisitor {
|
|
13
|
-
declare public element: SwaggerSchemesElement;
|
|
14
|
-
|
|
15
|
-
constructor(options: FallbackVisitorOptions) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.element = new SwaggerSchemesElement();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ArrayElement(path: Path<ArrayElement>) {
|
|
21
|
-
const arrayElement = path.node;
|
|
22
|
-
|
|
23
|
-
this.element = this.element.concat(cloneDeep(arrayElement));
|
|
24
|
-
|
|
25
|
-
path.stop();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default SchemesVisitor;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, Element } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import SwaggerSecurityElement from '../../../elements/nces/SwaggerSecurity.ts';
|
|
5
|
-
import { BaseSpecificationVisitor, BaseSpecificationVisitorOptions } from './bases.ts';
|
|
6
|
-
|
|
7
|
-
export type { BaseSpecificationVisitorOptions as SecurityVisitorOptions };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class SecurityVisitor extends BaseSpecificationVisitor {
|
|
13
|
-
declare public readonly element: SwaggerSecurityElement;
|
|
14
|
-
|
|
15
|
-
constructor(options: BaseSpecificationVisitorOptions) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.element = new SwaggerSecurityElement();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ArrayElement(path: Path<ArrayElement>) {
|
|
21
|
-
const arrayElement = path.node;
|
|
22
|
-
|
|
23
|
-
arrayElement.forEach((item: Element): void => {
|
|
24
|
-
const specPath = ['document', 'objects', 'SecurityRequirement'];
|
|
25
|
-
const element = this.toRefractedElement(specPath, item);
|
|
26
|
-
this.element.push(element);
|
|
27
|
-
});
|
|
28
|
-
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
29
|
-
|
|
30
|
-
path.stop();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default SecurityVisitor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { StringElement } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { toValue } from '@speclynx/apidom-core';
|
|
3
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
4
|
-
|
|
5
|
-
import SwaggerVersionElement from '../../../elements/SwaggerVersion.ts';
|
|
6
|
-
import { BaseSpecificationVisitor, BaseSpecificationVisitorOptions } from './bases.ts';
|
|
7
|
-
|
|
8
|
-
export type { BaseSpecificationVisitorOptions as SwaggerVisitorOptions };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
class SwaggerVisitor extends BaseSpecificationVisitor {
|
|
14
|
-
declare public element: SwaggerVersionElement;
|
|
15
|
-
|
|
16
|
-
StringElement(path: Path<StringElement>) {
|
|
17
|
-
const stringElement = path.node;
|
|
18
|
-
const swaggerVersionElement = new SwaggerVersionElement(
|
|
19
|
-
toValue(stringElement) as string | undefined,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
this.copyMetaAndAttributes(stringElement, swaggerVersionElement);
|
|
23
|
-
|
|
24
|
-
this.element = swaggerVersionElement;
|
|
25
|
-
path.stop();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default SwaggerVisitor;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ArrayElement, Element } from '@speclynx/apidom-datamodel';
|
|
2
|
-
import { Path } from '@speclynx/apidom-traverse';
|
|
3
|
-
|
|
4
|
-
import SwaggerTagsElement from '../../../elements/nces/SwaggerTags.ts';
|
|
5
|
-
import { BaseSpecificationVisitor, BaseSpecificationVisitorOptions } from './bases.ts';
|
|
6
|
-
|
|
7
|
-
export type { BaseSpecificationVisitorOptions as TagsVisitorOptions };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class TagsVisitor extends BaseSpecificationVisitor {
|
|
13
|
-
declare public readonly element: SwaggerTagsElement;
|
|
14
|
-
|
|
15
|
-
constructor(options: BaseSpecificationVisitorOptions) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.element = new SwaggerTagsElement();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ArrayElement(path: Path<ArrayElement>) {
|
|
21
|
-
const arrayElement = path.node;
|
|
22
|
-
|
|
23
|
-
arrayElement.forEach((item: Element): void => {
|
|
24
|
-
const specPath = ['document', 'objects', 'Tag'];
|
|
25
|
-
const element = this.toRefractedElement(specPath, item);
|
|
26
|
-
this.element.push(element);
|
|
27
|
-
});
|
|
28
|
-
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
29
|
-
|
|
30
|
-
path.stop();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default TagsVisitor;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Mixin } from 'ts-mixer';
|
|
2
|
-
|
|
3
|
-
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
4
|
-
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor.ts';
|
|
5
|
-
import FixedFieldsVisitor, { FixedFieldsVisitorOptions } from '../generics/FixedFieldsVisitor.ts';
|
|
6
|
-
import PatternedFieldsVisitor, {
|
|
7
|
-
PatternedFieldsVisitorOptions,
|
|
8
|
-
} from '../generics/PatternedFieldsVisitor.ts';
|
|
9
|
-
import MapVisitor, { MapVisitorOptions } from '../generics/MapVisitor.ts';
|
|
10
|
-
import AlternatingVisitor, { AlternatingVisitorOptions } from '../generics/AlternatingVisitor.ts';
|
|
11
|
-
import MixedFieldsVisitor, { MixedFieldsVisitorOptions } from '../generics/MixedFieldsVisitor.ts';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Base class for visitors using Mixin(SpecificationVisitor, FallbackVisitor)
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export const BaseSpecificationVisitor = Mixin(SpecificationVisitor, FallbackVisitor);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export interface BaseSpecificationVisitorOptions
|
|
23
|
-
extends SpecificationVisitorOptions, FallbackVisitorOptions {}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Base class for visitors using Mixin(FixedFieldsVisitor, FallbackVisitor)
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export const BaseFixedFieldsVisitor = Mixin(FixedFieldsVisitor, FallbackVisitor);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export interface BaseFixedFieldsVisitorOptions
|
|
35
|
-
extends FixedFieldsVisitorOptions, FallbackVisitorOptions {}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Base class for visitors using Mixin(PatternedFieldsVisitor, FallbackVisitor)
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
export const BasePatternedFieldsVisitor = Mixin(PatternedFieldsVisitor, FallbackVisitor);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
|
-
export interface BasePatternedFieldsVisitorOptions
|
|
47
|
-
extends PatternedFieldsVisitorOptions, FallbackVisitorOptions {}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Base class for visitors using Mixin(MapVisitor, FallbackVisitor)
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export const BaseMapVisitor = Mixin(MapVisitor, FallbackVisitor);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export interface BaseMapVisitorOptions extends MapVisitorOptions, FallbackVisitorOptions {}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Base class for visitors using Mixin(AlternatingVisitor, FallbackVisitor)
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
export const BaseAlternatingVisitor = Mixin(AlternatingVisitor, FallbackVisitor);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export interface BaseAlternatingVisitorOptions
|
|
70
|
-
extends AlternatingVisitorOptions, FallbackVisitorOptions {}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Base class for visitors using Mixin(MixedFieldsVisitor, FallbackVisitor)
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export const BaseMixedFieldsVisitor = Mixin(MixedFieldsVisitor, FallbackVisitor);
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @public
|
|
80
|
-
*/
|
|
81
|
-
export interface BaseMixedFieldsVisitorOptions
|
|
82
|
-
extends MixedFieldsVisitorOptions, FallbackVisitorOptions {}
|