Please check this commit I made to demo the issue.
In test/petstore_15/Pet.yaml, discriminator mapping works fine:
discriminator:
propertyName: type
mapping:
cat: Cat.yaml
dog: Dog.yaml
But in test/petstore_16/Pet.yaml:
discriminator:
propertyName: type
mapping:
cat: '#/components/schemas/Cat'
dog: '#/components/schemas/Dog'
It throws this expection:
TypeError: Cannot read properties of undefined (reading 'value')
at /Users/joshua/Projects/openapi-merger/src/util.js:2:796
at Array.every (<anonymous>)
at sliceObject (/Users/joshua/Projects/openapi-merger/src/util.js:2:652)
at ComponentManager.create (/Users/joshua/Projects/openapi-merger/src/components.js:2:1917)
at ComponentManager.getOrCreate (/Users/joshua/Projects/openapi-merger/src/components.js:2:2423)
at Merger.handleRef (/Users/joshua/Projects/openapi-merger/src/merger.js:14:381)
at Merger.handleDiscriminator (/Users/joshua/Projects/openapi-merger/src/merger.js:22:994)
at Merger.mergeRefs (/Users/joshua/Projects/openapi-merger/src/merger.js:13:1188)
at async Merger.mergeRefs (/Users/joshua/Projects/openapi-merger/src/merger.js:13:1307)
at async Merger.mergeRefs (/Users/joshua/Projects/openapi-merger/src/merger.js:13:1307)
at async Merger.mergeRefs (/Users/joshua/Projects/openapi-merger/src/merger.js:13:1307)
at async Merger.merge (/Users/joshua/Projects/openapi-merger/src/merger.js:13:103)
at async main (/Users/joshua/Projects/openapi-merger/src/main.js:2:621)
at async runMerger (test_merger.js:17:3)
at async Context.<anonymous> (test_merger.js:99:5)
I was trying to debug this issue by myself, but turns out I have no idea how the merger work internally.
Hope the issue is clear enough, thanks for the library!
@tx-ba1666 Thank you for the contributing! I'm sorry my code is dirty and poor documentation.
I've released the fixed version, so please try it and let me know if there are any problems.
https://github.com/kota65535/openapi-merger/commit/ac29f1501e0242a7d0a8a9eafc79824e7de9e08b
Please check this commit I made to demo the issue.
In
test/petstore_15/Pet.yaml
, discriminator mapping works fine:But in
test/petstore_16/Pet.yaml
:It throws this expection:
I was trying to debug this issue by myself, but turns out I have no idea how the merger work internally. Hope the issue is clear enough, thanks for the library!