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