serverless-openapi-documenter 0.0.123 → 0.0.124-beta.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/README.md +4 -2
- package/openapi.json +1222 -0
- package/package.json +2 -2
- package/src/schemaHandler.js +30 -15
- package/test.js +204 -0
- package/test2.js +146 -0
- package/test3.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.124-beta.1",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@apidevtools/json-schema-ref-parser": "^9.1.0",
|
|
52
|
-
"@redocly/openapi-core": "^1.2.0",
|
|
53
52
|
"@usebruno/converters": "^0.16.0",
|
|
53
|
+
"@redocly/openapi-core": "^1.34.5",
|
|
54
54
|
"chalk": "^4.1.2",
|
|
55
55
|
"js-yaml": "^4.1.1",
|
|
56
56
|
"json-schema-for-openapi": "^0.5.0",
|
package/src/schemaHandler.js
CHANGED
|
@@ -16,6 +16,12 @@ class SchemaHandler {
|
|
|
16
16
|
this.documentation = serverless.service.custom.documentation;
|
|
17
17
|
this.openAPI = openAPI;
|
|
18
18
|
|
|
19
|
+
this.shouldConvert = true;
|
|
20
|
+
if (/(3\.1\.\d)/g.test(this.openAPI.openapi)) this.shouldConvert = false;
|
|
21
|
+
|
|
22
|
+
this.logger.verbose(`OpenAPI version: ${this.openAPI.openapi}`);
|
|
23
|
+
this.logger.verbose(`Convert Schemas: ${this.shouldConvert}`);
|
|
24
|
+
|
|
19
25
|
this.modelReferences = {};
|
|
20
26
|
|
|
21
27
|
this.__standardiseModels();
|
|
@@ -53,7 +59,7 @@ class SchemaHandler {
|
|
|
53
59
|
model.schema = null;
|
|
54
60
|
model.schemas = {};
|
|
55
61
|
for (const key in model.content) {
|
|
56
|
-
Object.assign(model.schemas, {[key]: {schema: model.content[key].schema}});
|
|
62
|
+
Object.assign(model.schemas, { [key]: { schema: model.content[key].schema } });
|
|
57
63
|
}
|
|
58
64
|
// model.schema = model.content[contentType].schema;
|
|
59
65
|
}
|
|
@@ -82,7 +88,7 @@ class SchemaHandler {
|
|
|
82
88
|
for (const model of this.models) {
|
|
83
89
|
const modelName = model.name;
|
|
84
90
|
const schemas = []
|
|
85
|
-
if (model.schema){
|
|
91
|
+
if (model.schema) {
|
|
86
92
|
// const modelSchema = model.schema;
|
|
87
93
|
schemas.push(model.schema)
|
|
88
94
|
} else {
|
|
@@ -119,8 +125,7 @@ class SchemaHandler {
|
|
|
119
125
|
}
|
|
120
126
|
} else {
|
|
121
127
|
throw new Error(
|
|
122
|
-
`There was an error converting the ${
|
|
123
|
-
model.name
|
|
128
|
+
`There was an error converting the ${model.name
|
|
124
129
|
} schema. Model received looks like: \n\n${JSON.stringify(
|
|
125
130
|
model
|
|
126
131
|
)}. The convereted schema looks like \n\n${JSON.stringify(
|
|
@@ -179,18 +184,30 @@ class SchemaHandler {
|
|
|
179
184
|
}
|
|
180
185
|
);
|
|
181
186
|
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
if (this.shouldConvert) {
|
|
188
|
+
this.logger.verbose(
|
|
189
|
+
`dereferenced model: ${JSON.stringify(dereferencedSchema)}`
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
this.logger.verbose(`converting model: ${name}`);
|
|
193
|
+
const convertedSchemas = SchemaConvertor.convert(
|
|
194
|
+
dereferencedSchema,
|
|
195
|
+
name
|
|
196
|
+
);
|
|
185
197
|
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
this.logger.verbose(
|
|
199
|
+
`converted schemas: ${JSON.stringify(convertedSchemas)}`
|
|
200
|
+
);
|
|
201
|
+
return convertedSchemas;
|
|
202
|
+
}
|
|
188
203
|
|
|
189
204
|
this.logger.verbose(
|
|
190
|
-
`
|
|
205
|
+
`dereferenced model: ${JSON.stringify({
|
|
206
|
+
schemas: { [name]: dereferencedSchema },
|
|
207
|
+
})}`
|
|
191
208
|
);
|
|
192
209
|
|
|
193
|
-
return
|
|
210
|
+
return { schemas: { [name]: dereferencedSchema } };
|
|
194
211
|
}
|
|
195
212
|
|
|
196
213
|
async __dereferenceSchema(schema) {
|
|
@@ -292,10 +309,8 @@ class SchemaHandler {
|
|
|
292
309
|
__HTTPError(error, model) {
|
|
293
310
|
if (error.message.includes("HTTP ERROR")) {
|
|
294
311
|
throw new Error(
|
|
295
|
-
`There was an error dereferencing ${
|
|
296
|
-
|
|
297
|
-
} schema. \n\n dereferencing message: ${
|
|
298
|
-
error.message
|
|
312
|
+
`There was an error dereferencing ${model.name
|
|
313
|
+
} schema. \n\n dereferencing message: ${error.message
|
|
299
314
|
} \n\n Model received: ${JSON.stringify(model)}`
|
|
300
315
|
);
|
|
301
316
|
}
|
package/test.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
const $RefParser = require("@apidevtools/json-schema-ref-parser");
|
|
2
|
+
|
|
3
|
+
const schema = {
|
|
4
|
+
$id: "http://schemas.aat.org.uk/build/ProgrammeRegistration.json",
|
|
5
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
6
|
+
title: "ProgrammeRegistration",
|
|
7
|
+
description: "Programme registration schema",
|
|
8
|
+
required: ["programmeRegistrationDetail"],
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
programmeRegistrationDetail: {
|
|
13
|
+
$ref: "#/definitions/ProgrammeRegistrationType",
|
|
14
|
+
},
|
|
15
|
+
programmeRegistrationQuestionResponse: {
|
|
16
|
+
anyOf: [
|
|
17
|
+
{ type: "null" },
|
|
18
|
+
{
|
|
19
|
+
type: "object",
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
properties: {
|
|
22
|
+
questions: {
|
|
23
|
+
type: "array",
|
|
24
|
+
items: { $ref: "#/definitions/QuestionResponse" },
|
|
25
|
+
minItems: 1,
|
|
26
|
+
maxItems: 30,
|
|
27
|
+
uniqueItems: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
autoOrderCreate: {
|
|
34
|
+
anyOf: [{ type: "boolean", default: false }, { type: "null" }],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
version: "1.1.1",
|
|
38
|
+
definitions: {
|
|
39
|
+
ProgrammeRegistrationType: {
|
|
40
|
+
title: "ProgrammeRegistrationType",
|
|
41
|
+
description: "programme registration type",
|
|
42
|
+
type: "object",
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
required: [
|
|
45
|
+
"programmeRegistrationId",
|
|
46
|
+
"contactId",
|
|
47
|
+
"trainingProviderOrganisationId",
|
|
48
|
+
"qualificationId",
|
|
49
|
+
"startingLevel",
|
|
50
|
+
],
|
|
51
|
+
properties: {
|
|
52
|
+
programmeRegistrationId: { $ref: "#/definitions/UUID" },
|
|
53
|
+
programmeRegistrationCRMId: { $ref: "#/definitions/UUID" },
|
|
54
|
+
contactId: { $ref: "#/definitions/UUID" },
|
|
55
|
+
trainingProviderOrganisationId: { $ref: "#/definitions/UUID" },
|
|
56
|
+
qualificationId: { $ref: "#/definitions/UUID" },
|
|
57
|
+
qualificationLocalCode: {
|
|
58
|
+
anyOf: [{ type: "null" }, { type: "string" }],
|
|
59
|
+
},
|
|
60
|
+
startingLevel: { $ref: "#/definitions/UUID" },
|
|
61
|
+
expectedEndLevel: {
|
|
62
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
63
|
+
},
|
|
64
|
+
currentLevel: {
|
|
65
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
66
|
+
},
|
|
67
|
+
registrationDate: {
|
|
68
|
+
anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
69
|
+
},
|
|
70
|
+
fundingType: {
|
|
71
|
+
anyOf: [
|
|
72
|
+
{ type: "null" },
|
|
73
|
+
{ $ref: "#/definitions/ProgrammeRegistrationFundingType" },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
endDate: {
|
|
77
|
+
anyOf: [{ type: "null" }, { $ref: "#/definitions/AATDate" }],
|
|
78
|
+
},
|
|
79
|
+
fundingTypeMembershipFees: {
|
|
80
|
+
anyOf: [
|
|
81
|
+
{ type: "null" },
|
|
82
|
+
{ $ref: "#/definitions/ProgrammeRegistrationFundingType" },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
apprenticeship: { type: "boolean", default: false },
|
|
86
|
+
apprenticeshipStartDate: {
|
|
87
|
+
anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
88
|
+
},
|
|
89
|
+
fullTime: { type: "boolean", default: false },
|
|
90
|
+
distanceLearning: { type: "boolean", default: false },
|
|
91
|
+
payingOrganisationId: {
|
|
92
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
93
|
+
},
|
|
94
|
+
employmentId: {
|
|
95
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
96
|
+
},
|
|
97
|
+
poNumber: {
|
|
98
|
+
anyOf: [{ type: "string", maxLength: 50 }, { type: "null" }],
|
|
99
|
+
},
|
|
100
|
+
poRequester: {
|
|
101
|
+
anyOf: [{ type: "string", maxLength: 50 }, { type: "null" }],
|
|
102
|
+
},
|
|
103
|
+
assessmentPoNumber: {
|
|
104
|
+
anyOf: [{ type: "string", maxLength: 50 }, { type: "null" }],
|
|
105
|
+
},
|
|
106
|
+
smartEPAId: {
|
|
107
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
108
|
+
},
|
|
109
|
+
autoOrderCreate: {
|
|
110
|
+
anyOf: [{ type: "boolean", default: false }, { type: "null" }],
|
|
111
|
+
},
|
|
112
|
+
membershipApplicationId: {
|
|
113
|
+
anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
114
|
+
},
|
|
115
|
+
gatewayDate: {
|
|
116
|
+
anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
117
|
+
},
|
|
118
|
+
registrationStatus: {
|
|
119
|
+
anyOf: [{ type: "null" }, { type: "string" }],
|
|
120
|
+
},
|
|
121
|
+
registrationStatusDate: {
|
|
122
|
+
anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
123
|
+
},
|
|
124
|
+
givenName: { anyOf: [{ type: "null" }, { type: "string" }] },
|
|
125
|
+
familyName: { anyOf: [{ type: "null" }, { type: "string" }] },
|
|
126
|
+
memberId: { anyOf: [{ type: "null" }, { type: "string" }] },
|
|
127
|
+
birthDate: {
|
|
128
|
+
anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
129
|
+
},
|
|
130
|
+
epaRegisteredOn: {
|
|
131
|
+
anyOf: [
|
|
132
|
+
{ type: "null" },
|
|
133
|
+
{
|
|
134
|
+
type: "boolean",
|
|
135
|
+
description:
|
|
136
|
+
"Indicates the user is studying the associated apprenticeship",
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
QuestionResponse: {
|
|
143
|
+
title: "QuestionResponse",
|
|
144
|
+
description: "response to a question",
|
|
145
|
+
type: "object",
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
required: ["questionId", "responseId", "response"],
|
|
148
|
+
properties: {
|
|
149
|
+
responseId: { $ref: "#/definitions/UUID" },
|
|
150
|
+
questionId: { $ref: "#/definitions/UUID" },
|
|
151
|
+
response: {
|
|
152
|
+
type: "object",
|
|
153
|
+
anyOf: [
|
|
154
|
+
{ text: { type: "string" } },
|
|
155
|
+
{ multiLineText: { type: "string" } },
|
|
156
|
+
{ currency: { type: "number" } },
|
|
157
|
+
{ date: { $ref: "#/source/base/AATDate.json" } },
|
|
158
|
+
{ decimal: { type: "number" } },
|
|
159
|
+
{ optionSet: { type: "string" } },
|
|
160
|
+
{ wholeNumber: { type: "integer" } },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
UUID: {
|
|
166
|
+
title: "UUID",
|
|
167
|
+
description: "Universally Unique Identifier (all lowercase)",
|
|
168
|
+
type: "string",
|
|
169
|
+
pattern: "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",
|
|
170
|
+
},
|
|
171
|
+
AATDate: {
|
|
172
|
+
title: "AATDate",
|
|
173
|
+
description: "AAT Date formatted",
|
|
174
|
+
type: "string",
|
|
175
|
+
examples: ["2014-07-17T10:02:21Z"],
|
|
176
|
+
},
|
|
177
|
+
ProgrammeRegistrationFundingType: {
|
|
178
|
+
title: "ProgrammeRegistrationFundingType",
|
|
179
|
+
description: "funding types for programme registrations",
|
|
180
|
+
type: "string",
|
|
181
|
+
enum: [
|
|
182
|
+
"Employer",
|
|
183
|
+
"Student",
|
|
184
|
+
"Training Provider",
|
|
185
|
+
"AAT(SA)",
|
|
186
|
+
"AAT NZICA",
|
|
187
|
+
"Unknown",
|
|
188
|
+
"Government",
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const main = async () => {
|
|
195
|
+
let deReferencedSchema = await $RefParser
|
|
196
|
+
.dereference("schemas.aat.org.uk/build/ProgrammeRegistration.json")
|
|
197
|
+
.catch((err) => {
|
|
198
|
+
throw err;
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
console.log(deReferencedSchema);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
main().catch((err) => console.error(err));
|
package/test2.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const $RefParser = require("@apidevtools/json-schema-ref-parser");
|
|
2
|
+
|
|
3
|
+
const schema = {
|
|
4
|
+
$id: "http://schemas.aat.org.uk/build/TrainingProviderApprovalDetail.json",
|
|
5
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
6
|
+
title: "TrainingProviderApprovalDetail",
|
|
7
|
+
description: "Training Provider Approval",
|
|
8
|
+
required: ["approval"],
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
abc: { type: "string" },
|
|
13
|
+
// approval: { $ref: "#/definitions/TrainingProviderApproval" },
|
|
14
|
+
// approvalQuestionResponse: {
|
|
15
|
+
// anyOf: [
|
|
16
|
+
// {
|
|
17
|
+
// type: "object",
|
|
18
|
+
// properties: {
|
|
19
|
+
// questions: {
|
|
20
|
+
// type: "array",
|
|
21
|
+
// items: { $ref: "#/definitions/QuestionResponse" },
|
|
22
|
+
// minItems: 1,
|
|
23
|
+
// maxItems: 30,
|
|
24
|
+
// uniqueItems: true,
|
|
25
|
+
// },
|
|
26
|
+
// },
|
|
27
|
+
// },
|
|
28
|
+
// { type: "null" },
|
|
29
|
+
// ],
|
|
30
|
+
// },
|
|
31
|
+
},
|
|
32
|
+
version: "1.1.1",
|
|
33
|
+
definitions: {
|
|
34
|
+
// TrainingProviderApproval: {
|
|
35
|
+
// title: "TrainingProviderApproval",
|
|
36
|
+
// description: "Training Provider Approval",
|
|
37
|
+
// required: [
|
|
38
|
+
// "TPapprovalId",
|
|
39
|
+
// "approvalCRMId",
|
|
40
|
+
// "qualificationId",
|
|
41
|
+
// "status",
|
|
42
|
+
// "qualificationName",
|
|
43
|
+
// "organisationId",
|
|
44
|
+
// ],
|
|
45
|
+
// additionalProperties: false,
|
|
46
|
+
// type: "object",
|
|
47
|
+
// properties: {
|
|
48
|
+
// TPapprovalId: { $ref: "#/definitions/UUID" },
|
|
49
|
+
// TPapprovalCRMId: {
|
|
50
|
+
// anyOf: [{ $ref: "#/definitions/UUID" }, { type: "null" }],
|
|
51
|
+
// },
|
|
52
|
+
// approvalCRMId: { $ref: "#/definitions/UUID" },
|
|
53
|
+
// organisationId: { $ref: "#/definitions/UUID" },
|
|
54
|
+
// qualificationName: { type: "string", maxLength: 100 },
|
|
55
|
+
// qualificationShortName: {
|
|
56
|
+
// anyOf: [{ type: "string", maxLength: 100 }, { type: "null" }],
|
|
57
|
+
// },
|
|
58
|
+
// localCode: {
|
|
59
|
+
// anyOf: [{ type: "string", maxLength: 20 }, { type: "null" }],
|
|
60
|
+
// },
|
|
61
|
+
// aatId: { anyOf: [{ type: "number" }, { type: "null" }] },
|
|
62
|
+
// qualificationId: { $ref: "#/definitions/UUID" },
|
|
63
|
+
// status: {
|
|
64
|
+
// type: "string",
|
|
65
|
+
// enum: [
|
|
66
|
+
// "Sales Prospect",
|
|
67
|
+
// "EOI Sent",
|
|
68
|
+
// "EOI Received",
|
|
69
|
+
// "EOI More Information Requested",
|
|
70
|
+
// "EOI Declined",
|
|
71
|
+
// "EOI Closed",
|
|
72
|
+
// "Application On Hold By TP",
|
|
73
|
+
// "Application Pack Sent",
|
|
74
|
+
// "Application Pending",
|
|
75
|
+
// "Approval Visit Scheduled",
|
|
76
|
+
// "Approval Visit Action Plan",
|
|
77
|
+
// "Application Closed",
|
|
78
|
+
// "Application Withdrawn",
|
|
79
|
+
// "Approved",
|
|
80
|
+
// "Conditionally Approved",
|
|
81
|
+
// "Referred to Conduct & Compliance",
|
|
82
|
+
// "Rejected",
|
|
83
|
+
// "Inactive",
|
|
84
|
+
// "Withdrawn",
|
|
85
|
+
// ],
|
|
86
|
+
// },
|
|
87
|
+
// statusDate: {
|
|
88
|
+
// anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
89
|
+
// },
|
|
90
|
+
// fromDate: {
|
|
91
|
+
// anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
92
|
+
// },
|
|
93
|
+
// untilDate: {
|
|
94
|
+
// anyOf: [{ $ref: "#/definitions/AATDate" }, { type: "null" }],
|
|
95
|
+
// },
|
|
96
|
+
// },
|
|
97
|
+
// },
|
|
98
|
+
QuestionResponse: {
|
|
99
|
+
title: "QuestionResponse",
|
|
100
|
+
description: "response to a question",
|
|
101
|
+
type: "object",
|
|
102
|
+
additionalProperties: false,
|
|
103
|
+
required: ["questionId", "responseId", "response"],
|
|
104
|
+
properties: {
|
|
105
|
+
responseId: { $ref: "#/definitions/UUID" },
|
|
106
|
+
questionId: { $ref: "#/definitions/UUID" },
|
|
107
|
+
response: {
|
|
108
|
+
type: "object",
|
|
109
|
+
anyOf: [
|
|
110
|
+
{ text: { type: "string" } },
|
|
111
|
+
{ multiLineText: { type: "string" } },
|
|
112
|
+
{ currency: { type: "number" } },
|
|
113
|
+
{ date: { $ref: "#/source/base/AATDate.json" } },
|
|
114
|
+
{ decimal: { type: "number" } },
|
|
115
|
+
{ optionSet: { type: "string" } },
|
|
116
|
+
{ wholeNumber: { type: "integer" } },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
UUID: {
|
|
122
|
+
title: "UUID",
|
|
123
|
+
description: "Universally Unique Identifier (all lowercase)",
|
|
124
|
+
type: "string",
|
|
125
|
+
pattern: "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",
|
|
126
|
+
},
|
|
127
|
+
AATDate: {
|
|
128
|
+
title: "AATDate",
|
|
129
|
+
description: "AAT Date formatted",
|
|
130
|
+
type: "string",
|
|
131
|
+
examples: ["2014-07-17T10:02:21Z"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const schema2 = { type: "object", properties: { a: { type: "string" } } };
|
|
137
|
+
|
|
138
|
+
const main = async () => {
|
|
139
|
+
const bundledSchema = await $RefParser.bundle(schema).catch((err) => {
|
|
140
|
+
throw err;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
console.log(bundledSchema);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
main().catch((err) => console.error(err));
|
package/test3.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const {
|
|
2
|
+
Config,
|
|
3
|
+
lintFromString,
|
|
4
|
+
stringifyYaml,
|
|
5
|
+
createConfig,
|
|
6
|
+
} = require("@redocly/openapi-core");
|
|
7
|
+
|
|
8
|
+
const openAPI = require("./openapi.json");
|
|
9
|
+
|
|
10
|
+
const main = async () => {
|
|
11
|
+
const config = await createConfig({
|
|
12
|
+
apis: {},
|
|
13
|
+
rules: this.REDOCLY_RULES,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const apiDesc = stringifyYaml(openAPI);
|
|
17
|
+
|
|
18
|
+
const output = await lintFromString({
|
|
19
|
+
source: apiDesc,
|
|
20
|
+
config: config,
|
|
21
|
+
}).catch((err) => {
|
|
22
|
+
console.error(err);
|
|
23
|
+
throw err;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
console.log(output);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
main().catch((err) => console.error(err));
|