Skip to content

Switch to AJV for deserialization and Simplify Implementation #68

Closed
@RichiCoder1

Description

@RichiCoder1

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions