@pactflow/openapi-pact-comparator 2.0.0 → 2.0.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/dist/cli.cjs +6246 -7834
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.cjs
CHANGED
|
@@ -4132,10 +4132,6 @@ const cleanupDiscriminators = (s) => {
|
|
|
4132
4132
|
if (s.discriminator?.propertyName && s.oneOf) {
|
|
4133
4133
|
s.required = uniq([...(s.required || []), s.discriminator.propertyName]);
|
|
4134
4134
|
}
|
|
4135
|
-
// no-op from a validation perspective
|
|
4136
|
-
if (s.discriminator?.mapping) {
|
|
4137
|
-
delete s.discriminator.mapping;
|
|
4138
|
-
}
|
|
4139
4135
|
if (s.discriminator && !s.oneOf) {
|
|
4140
4136
|
delete s.discriminator;
|
|
4141
4137
|
}
|
|
@@ -19884,8 +19880,6 @@ function requireDiscriminator () {
|
|
|
19884
19880
|
const tagName = schema.propertyName;
|
|
19885
19881
|
if (typeof tagName != "string")
|
|
19886
19882
|
throw new Error("discriminator: requires propertyName");
|
|
19887
|
-
if (schema.mapping)
|
|
19888
|
-
throw new Error("discriminator: mapping is not supported");
|
|
19889
19883
|
if (!oneOf)
|
|
19890
19884
|
throw new Error("discriminator: requires oneOf keyword");
|
|
19891
19885
|
const valid = gen.let("valid", false);
|
|
@@ -19914,6 +19908,37 @@ function requireDiscriminator () {
|
|
|
19914
19908
|
const oneOfMapping = {};
|
|
19915
19909
|
const topRequired = hasRequired(parentSchema);
|
|
19916
19910
|
let tagRequired = true;
|
|
19911
|
+
if (schema.mapping) {
|
|
19912
|
+
const refToIndex = {};
|
|
19913
|
+
for (let i = 0; i < oneOf.length; i++) {
|
|
19914
|
+
const sch = oneOf[i];
|
|
19915
|
+
if (sch === null || sch === void 0 ? void 0 : sch.$ref) {
|
|
19916
|
+
refToIndex[sch.$ref] = i;
|
|
19917
|
+
}
|
|
19918
|
+
}
|
|
19919
|
+
for (const [tagValue, ref] of Object.entries(schema.mapping)) {
|
|
19920
|
+
const i = refToIndex[ref];
|
|
19921
|
+
if (i === undefined) {
|
|
19922
|
+
throw new Error(`discriminator: mapping "${tagValue}" does not correspond to any oneOf entry`);
|
|
19923
|
+
}
|
|
19924
|
+
addMapping(tagValue, i);
|
|
19925
|
+
}
|
|
19926
|
+
for (let i = 0; i < oneOf.length; i++) {
|
|
19927
|
+
let sch = oneOf[i];
|
|
19928
|
+
if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
|
|
19929
|
+
const ref = sch.$ref;
|
|
19930
|
+
sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref);
|
|
19931
|
+
if (sch instanceof compile_1.SchemaEnv)
|
|
19932
|
+
sch = sch.schema;
|
|
19933
|
+
if (sch === undefined)
|
|
19934
|
+
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
|
19935
|
+
}
|
|
19936
|
+
tagRequired = tagRequired && (topRequired || hasRequired(sch));
|
|
19937
|
+
}
|
|
19938
|
+
if (!tagRequired)
|
|
19939
|
+
throw new Error(`discriminator: "${tagName}" must be required`);
|
|
19940
|
+
return oneOfMapping;
|
|
19941
|
+
}
|
|
19917
19942
|
for (let i = 0; i < oneOf.length; i++) {
|
|
19918
19943
|
let sch = oneOf[i];
|
|
19919
19944
|
if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
|