one more riddle :slightly_smiling_face: how to add...
# pact-js
d
one more riddle 🙂 how to add element inside json array ? like
{z:[a,b,[d,e]]}
->`{z:[a,b,c,[d,e,f]]}` where
a
and
d
is one term and
b
c
e
f
other ( same ) term
y
that isn't valid json to begin with?
if you are conditionally/optionally expecting something to be there, you probably want two interactions.
d
edited a bit
there is field with array
and if adding
f
is kinda easy ( probably ) with
c
is pain
y
does your code act differently in both cases? or if the cases that
f
or
c
don't exist. have you read this https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes?
d
no, just one more case added
like expanding message with more fields
y
🤔 I'll mull it over and get back to you, and someone else may pop along in the meantime. Thanks @Dmitry Munda!
👍 1
I like the riddles hehe
d
and i have no idea how to make provider be backwards compatible in this case
added one more thing
where
a
and
d
is one term and
b
c
e
f
other ( same ) term
so some
{z:[like(a),eachLike(b),[like(a),eachLike(b)]]}
could work, but i didnt managed to make that work 😞
y
would you be able to fire up a sample repo at all on GitHub? I can take a look this weekend? you could use this as a start? https://github.com/pactflow/example-consumer/tree/master/src
d
will try 👍
b
Part of the trick here is that the value for
z
is a list of elements that can be either a something or a list of somethings? How deep does that typing nest (is it recursive, or just 1-deep)? Or are they heterogeneous? 🤔
d
most tricky part is - array, as it is simpler with true-json
this is like a journal - sequence of arrays, which in theory could be with different length and sequence of
a
and
d
so one more magic could be term, which could generate/expect
a
or
d