buildo / metarpheus-io-ts

Generate domain models and client interpreting metarpheus output
MIT License
7 stars 1 forks source link

Incorrect encoding of optional post parameters #75

Closed gabro closed 5 years ago

gabro commented 5 years ago

The change introduced in #70 does not take into account optional parameters.

Suppose you have a POST route that takes a single optional parameter, then metarpheus-io-ts produces this output, that does not compile:

// ...
data: {
  foo: m.Foo.encode(foo)
}
// ...

the correct encoding would be

// ...
data: {
  foo: t.union([m.Foo, t.undefined]).encode(foo)
}
// ...