Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to AJV for deserialization and Simplify Implementation #68

Closed
RichiCoder1 opened this issue Jul 27, 2022 · 0 comments
Closed

Switch to AJV for deserialization and Simplify Implementation #68

RichiCoder1 opened this issue Jul 27, 2022 · 0 comments

Comments

@RichiCoder1
Copy link

RichiCoder1 commented Jul 27, 2022

Currently this plugin uses class-transformer to handle serialization and deserialization of CloudFormation data.

This has a few problems at present:

  • The serialization breaks down in the face of unsupported JSON Schema Features
  • It ties the implementation to TypeScript's decorators which are soon to be completely deprecated, and results in a data model that might be foreign to a lot of JavaScript developers today (outside angular and nestjs)
  • Because of the above, it prevents JavaScript from working (though I'd personally always encourage TS over JS) (Support for JavaScript #8)
  • The project isn't also super alive right now: question: is the project still alive ? typestack/class-transformer#1272

I propose a simplification and breaking change in the plugin to instead:

  • Use the excellent Ajv JSON Schema Lib in combination with it's coercion mode for deserialization.
  • Instead of exposing every property via templating, use Ajv's typescript support to expose the data via standard JavaScript w/ typing support
  • For serialization, expose a toJSON that just stringifies enumerable properties (w/ validation) and mark CloudFormation's helpers as non-enumerable.

Hopefully the net result is something that provides a rich experience for end users, but greatly simplifies the generation/maintenance and makes code more standard TypeScript.

Happy to answer questions about implementation or contribute!

@RichiCoder1 RichiCoder1 changed the title Switch to AJV for deserialization Switch to AJV for deserialization and Simplify Implementation Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant