@microsoft/m365-spec-parser 0.2.4-alpha.396238b05.0 → 0.2.4-alpha.4a4474697.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/dist/index.esm2017.js +1 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +14 -4
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +1 -0
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +17 -5
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/specParser.d.ts +2 -0
- package/package.json +4 -4
package/dist/index.node.cjs.js
CHANGED
|
@@ -9,6 +9,7 @@ var fs = require('fs-extra');
|
|
|
9
9
|
var path = require('path');
|
|
10
10
|
var teamsManifest = require('@microsoft/teams-manifest');
|
|
11
11
|
var crypto = require('crypto');
|
|
12
|
+
var jsonSchemaRefParser = require('@apidevtools/json-schema-ref-parser');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
15
|
|
|
@@ -168,6 +169,7 @@ ConstantString.ResponseCodeFor20X = [
|
|
|
168
169
|
"207",
|
|
169
170
|
"208",
|
|
170
171
|
"226",
|
|
172
|
+
"2XX",
|
|
171
173
|
"default",
|
|
172
174
|
];
|
|
173
175
|
ConstantString.AllOperationMethods = [
|
|
@@ -2151,6 +2153,7 @@ class SpecParser {
|
|
|
2151
2153
|
};
|
|
2152
2154
|
this.pathOrSpec = pathOrDoc;
|
|
2153
2155
|
this.parser = new SwaggerParser__default['default']();
|
|
2156
|
+
this.refParser = new jsonSchemaRefParser.$RefParser();
|
|
2154
2157
|
this.options = Object.assign(Object.assign({}, this.defaultOptions), (options !== null && options !== void 0 ? options : {}));
|
|
2155
2158
|
}
|
|
2156
2159
|
/**
|
|
@@ -2164,12 +2167,15 @@ class SpecParser {
|
|
|
2164
2167
|
let hash = "";
|
|
2165
2168
|
try {
|
|
2166
2169
|
yield this.loadSpec();
|
|
2167
|
-
if (!this.
|
|
2170
|
+
if (!this.refParser.$refs.circular) {
|
|
2168
2171
|
yield this.parser.validate(this.spec);
|
|
2169
2172
|
}
|
|
2170
2173
|
else {
|
|
2174
|
+
// The following code hangs for Graph API, support will be added when SwaggerParser is updated.
|
|
2175
|
+
/*
|
|
2171
2176
|
const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));
|
|
2172
|
-
|
|
2177
|
+
await this.parser.validate(clonedUnResolveSpec);
|
|
2178
|
+
*/
|
|
2173
2179
|
}
|
|
2174
2180
|
}
|
|
2175
2181
|
catch (e) {
|
|
@@ -2197,7 +2203,7 @@ class SpecParser {
|
|
|
2197
2203
|
};
|
|
2198
2204
|
}
|
|
2199
2205
|
// Remote reference not supported
|
|
2200
|
-
const refPaths = this.
|
|
2206
|
+
const refPaths = this.refParser.$refs.paths();
|
|
2201
2207
|
// refPaths [0] is the current spec file path
|
|
2202
2208
|
if (refPaths.length > 1) {
|
|
2203
2209
|
errors.push({
|
|
@@ -2332,7 +2338,7 @@ class SpecParser {
|
|
|
2332
2338
|
throw new SpecParserError(ConstantString.CancelledMessage, exports.ErrorType.Cancelled);
|
|
2333
2339
|
}
|
|
2334
2340
|
const clonedUnResolveSpec = JSON.parse(JSON.stringify(newUnResolvedSpec));
|
|
2335
|
-
const newSpec =
|
|
2341
|
+
const newSpec = yield this.deReferenceSpec(clonedUnResolveSpec);
|
|
2336
2342
|
return [newUnResolvedSpec, newSpec];
|
|
2337
2343
|
}
|
|
2338
2344
|
catch (err) {
|
|
@@ -2343,6 +2349,12 @@ class SpecParser {
|
|
|
2343
2349
|
}
|
|
2344
2350
|
});
|
|
2345
2351
|
}
|
|
2352
|
+
deReferenceSpec(spec) {
|
|
2353
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2354
|
+
const result = yield this.refParser.dereference(spec);
|
|
2355
|
+
return result;
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2346
2358
|
/**
|
|
2347
2359
|
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
2348
2360
|
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
@@ -2488,7 +2500,7 @@ class SpecParser {
|
|
|
2488
2500
|
this.isSwaggerFile = true;
|
|
2489
2501
|
}
|
|
2490
2502
|
const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));
|
|
2491
|
-
this.spec =
|
|
2503
|
+
this.spec = yield this.deReferenceSpec(clonedUnResolveSpec);
|
|
2492
2504
|
}
|
|
2493
2505
|
});
|
|
2494
2506
|
}
|