Coder Social home page Coder Social logo

maas-schemas-ts's People

Contributors

cyberixae avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

maas-schemas-ts's Issues

Make error messages easier to read

Missing tokenId currently produces the following error.

File _customer-profile.json contains an invalid customerProfile example: Invalid value "TOKEN" supplied to : Default/balances: ((Partial<{ WMP: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) }> & { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) }) & { WMP: (UnknownRecord | UnknownArray | string | boolean | number | null) })/0: (Partial<{ WMP: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) }> & { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) })/1: { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) }/cx-test-token_v2: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }))/0: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })/0: Partial<{ currency: "WMP", amount: number }>/currency: "WMP"

At least it would be nice if we could translate (UnknownRecord | UnknownArray | string | boolean | number | null) to Defined as that is what it essentially means. In their current form the error messages are too verbose and hide the real error.

Automate io-ts code generation

At the moment we create/edit the code in this repository manually. However, this entire process could be automated. Based on quick research it seems we have three options.

  1. Keep updating the source code in this repository by hand
  2. Modify SchemaScript to fit our needs
  3. Create our own "SchemaScript" using io-ts-codegen

The main problem with updating this repository by hand is that it is incomplete, out of date and may not match the original schemas because of errors in the manual update process.

SchemaScript provide an automated way of transforming JSON Schema files into io-ts source code. However, the reference solver in SchemaScript is unable to resolve the references used in maas-schemas. It also requires adding arguments to comment fields of the original JSON Schema files which is a bit impractical. SchemaScript is open to contributions if we wish to adapt it to our needs. However, it is unclear how much work would be required to get it working since its implementation is limited and does not adhere to a JSON Schema test suite.

SchemaScript uses io-ts-codegen for io-ts source code generation. As another alternative, we could perhaps create our own JSON schema conversion tool. The code example provided in io-ts-codegen documentation shows how to transform a simplified version of JSON Schema into io-ts source code. The code example is even more limited than SchemaScript but might be a better starting point if SchemaScript is deemed unsuitable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.