johnstonskj / rust-atelier

Rust native core model for the AWS Smithy IDL
MIT License
77 stars 11 forks source link

[BUG] No way to save and restore semantic model #29

Closed stevelr closed 3 years ago

stevelr commented 3 years ago

The atelier Model doesn't implement serde::Serialize, so it can't be saved and restored through serialization.

A potential work-around might be to convert the model to json, save the json file, then load and convert from json back to smithy, however a trivial model converted this way fails to restore due to Issue #28

I consider this a significant limitation of smithy models. There needs to be a way to serialize and save a model. It would be ideal of both of the above methods (serde and smithy-json) worked, but json is more language-independent so that may be preferable.

The expectation is that Conversion to and from json is reliable and non-lossy. If it is at all lossy, then serde Serialize/Deserialize is a requirement.

stevelr commented 3 years ago

PR #30 addresses (at least some) of this for the json use case. I don't think it's was ever a requirement of the rust model (atelier_core::model::Model) to be Serializable, and making it serializable would have serious limitations: it's not polyglot, and it since it's not formally specified, it might create a false expectation of forward-compatibility. json conversion to and from Model accomplishes the requirement for model storage/serializability.

With that said, the rust model tools need more test coverage.

johnstonskj commented 3 years ago

I am going to close this one, the JSON AST is the correct representation for reading/writing the complete semantic model.

Agree more tests are required.