UNPKG

2.8 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const types_1 = require("./types");
4exports.createOas2SourceMap = () => {
5 return [
6 {
7 match: 'info',
8 type: types_1.NodeTypes.Info,
9 },
10 {
11 match: 'paths',
12 type: types_1.NodeTypes.Paths,
13 children: [
14 {
15 notMatch: '^x-',
16 type: types_1.NodeTypes.Path,
17 children: [
18 {
19 match: 'get|post|put|delete|options|head|patch|trace',
20 type: types_1.NodeTypes.Operation,
21 },
22 ],
23 },
24 ],
25 },
26 {
27 match: 'definitions',
28 type: types_1.NodeTypes.Models,
29 children: [
30 {
31 notMatch: '^x-',
32 type: types_1.NodeTypes.Model,
33 subtype: 'json_schema',
34 },
35 ],
36 },
37 parameters(types_1.NodeTypes.Shared),
38 responses(types_1.NodeTypes.Shared),
39 ];
40};
41const responses = (responseSource) => ({
42 match: 'responses',
43 type: types_1.NodeTypes.Responses,
44 children: [
45 {
46 notMatch: '^x-',
47 type: responseSource === types_1.NodeTypes.Shared ? types_1.NodeTypes.SharedResponse : types_1.NodeTypes.OperationResponse,
48 },
49 ],
50});
51const parameters = (parameterSource) => {
52 let type;
53 switch (parameterSource) {
54 case types_1.NodeTypes.Shared:
55 type = types_1.NodeTypes.SharedParameter;
56 break;
57 case types_1.NodeTypes.Operation:
58 type = types_1.NodeTypes.OperationParameter;
59 break;
60 case types_1.NodeTypes.Path:
61 type = types_1.NodeTypes.PathParameter;
62 break;
63 default:
64 type = types_1.NodeTypes.Parameter;
65 break;
66 }
67 return {
68 match: 'parameters',
69 type: types_1.NodeTypes.Parameters,
70 children: [
71 {
72 field: 'in',
73 match: 'path',
74 type,
75 subtype: 'path',
76 },
77 {
78 field: 'in',
79 match: 'header',
80 type,
81 subtype: 'header',
82 },
83 {
84 field: 'in',
85 match: 'query',
86 type,
87 subtype: 'query',
88 },
89 {
90 field: 'in',
91 match: 'body',
92 type,
93 subtype: 'body',
94 },
95 {
96 type,
97 },
98 ],
99 };
100};
101//# sourceMappingURL=sourceMap.js.map
\No newline at end of file