@conduit-client/model 3.12.0 → 3.13.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { ScalarType } from '../../types';
|
|
3
|
+
import type { ResolverError, MissingPointerError } from '@apidevtools/json-schema-ref-parser';
|
|
3
4
|
export type OpenAPISchema = OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
4
5
|
/**
|
|
5
6
|
* Check if an object is a reference object ($ref)
|
|
@@ -49,3 +50,5 @@ export declare function isReferencePath(obj: OpenAPIV3.PathItemObject): obj is O
|
|
|
49
50
|
* and checking for schema-specific properties.
|
|
50
51
|
*/
|
|
51
52
|
export declare function extractRootLevelSchemas(file: OpenAPIV3.Document): Record<string, OpenAPISchema>;
|
|
53
|
+
export declare function isResolverError(error: unknown): error is ResolverError;
|
|
54
|
+
export declare function isMissingPointerError(error: unknown): error is MissingPointerError;
|
package/dist/v1/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import * as url from "url";
|
|
|
7
7
|
import amf from "amf-client-js";
|
|
8
8
|
import path from "path";
|
|
9
9
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
10
|
-
import { MissingPointerError, ResolverError } from "@apidevtools/json-schema-ref-parser";
|
|
11
10
|
const BindingTypesEnum = ["wire", "imperative", "imperative-legacy", "mutation"];
|
|
12
11
|
class BaseTypeRegistry extends Map {
|
|
13
12
|
nameOf(t) {
|
|
@@ -13650,6 +13649,12 @@ function extractRootLevelSchemas(file) {
|
|
|
13650
13649
|
}
|
|
13651
13650
|
return schemas2;
|
|
13652
13651
|
}
|
|
13652
|
+
function isResolverError(error) {
|
|
13653
|
+
return error instanceof Error && "code" in error && error.code === "ERESOLVER";
|
|
13654
|
+
}
|
|
13655
|
+
function isMissingPointerError(error) {
|
|
13656
|
+
return error instanceof Error && "code" in error && error.code === "EMISSINGPOINTER";
|
|
13657
|
+
}
|
|
13653
13658
|
class SwaggerEnumerableScalarType extends SwaggerBaseType {
|
|
13654
13659
|
typeResolve() {
|
|
13655
13660
|
if (this.schema.enum && this.schema.enum.length > 0) {
|
|
@@ -15242,41 +15247,52 @@ async function parseSwaggerDocument(source, logger) {
|
|
|
15242
15247
|
$refs
|
|
15243
15248
|
};
|
|
15244
15249
|
} catch (error) {
|
|
15245
|
-
if (error
|
|
15246
|
-
const missingFile = error.source;
|
|
15250
|
+
if (isMissingPointerError(error)) {
|
|
15247
15251
|
const tokenMatch = error.message.match(/Token "([^"]+)"/);
|
|
15248
15252
|
const token = (tokenMatch == null ? void 0 : tokenMatch[1]) ?? "unknown";
|
|
15249
|
-
const
|
|
15250
|
-
|
|
15251
|
-
if (refInfo) {
|
|
15252
|
-
const { position, refValue } = refInfo;
|
|
15253
|
-
logger.error(
|
|
15254
|
-
position,
|
|
15255
|
-
`Cannot resolve reference '${refValue}': token '${token}' does not exist in '${filename}'`
|
|
15256
|
-
);
|
|
15257
|
-
} else {
|
|
15253
|
+
const missingFile = error.source;
|
|
15254
|
+
if (!missingFile) {
|
|
15258
15255
|
logger.error(
|
|
15259
15256
|
{ line: 0, column: 0 },
|
|
15260
|
-
`Cannot resolve reference: token '${token}' does not exist
|
|
15257
|
+
`Cannot resolve reference: token '${token}' does not exist`
|
|
15261
15258
|
);
|
|
15259
|
+
} else {
|
|
15260
|
+
const refInfo = findRefPositionInCache(missingFile, token);
|
|
15261
|
+
const filename = missingFile.split("/").pop() ?? missingFile;
|
|
15262
|
+
if (refInfo) {
|
|
15263
|
+
const { position, refValue } = refInfo;
|
|
15264
|
+
logger.error(
|
|
15265
|
+
position,
|
|
15266
|
+
`Cannot resolve reference '${refValue}': token '${token}' does not exist in '${filename}'`
|
|
15267
|
+
);
|
|
15268
|
+
} else {
|
|
15269
|
+
logger.error(
|
|
15270
|
+
{ line: 0, column: 0 },
|
|
15271
|
+
`Cannot resolve reference: token '${token}' does not exist in '${filename}'`
|
|
15272
|
+
);
|
|
15273
|
+
}
|
|
15262
15274
|
}
|
|
15263
15275
|
positionMapCache.clear();
|
|
15264
15276
|
throw error;
|
|
15265
15277
|
}
|
|
15266
|
-
if (error
|
|
15278
|
+
if (isResolverError(error)) {
|
|
15267
15279
|
const missingFile = error.source;
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
const { position, refValue } = refInfo;
|
|
15271
|
-
logger.error(
|
|
15272
|
-
position,
|
|
15273
|
-
`Cannot resolve external reference '${refValue}': file not found '${missingFile}'`
|
|
15274
|
-
);
|
|
15280
|
+
if (!missingFile) {
|
|
15281
|
+
logger.error({ line: 0, column: 0 }, `Cannot resolve reference: file not found`);
|
|
15275
15282
|
} else {
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15283
|
+
const refInfo = findRefPositionInCache(missingFile);
|
|
15284
|
+
if (refInfo) {
|
|
15285
|
+
const { position, refValue } = refInfo;
|
|
15286
|
+
logger.error(
|
|
15287
|
+
position,
|
|
15288
|
+
`Cannot resolve external reference '${refValue}': file not found '${missingFile}'`
|
|
15289
|
+
);
|
|
15290
|
+
} else {
|
|
15291
|
+
logger.error(
|
|
15292
|
+
{ line: 0, column: 0 },
|
|
15293
|
+
`Cannot resolve reference '${missingFile}': file not found`
|
|
15294
|
+
);
|
|
15295
|
+
}
|
|
15280
15296
|
}
|
|
15281
15297
|
positionMapCache.clear();
|
|
15282
15298
|
throw error;
|