amazon-ion / ion-cli

Apache License 2.0
34 stars 15 forks source link

Modify template to dynamically add module names in import #70

Closed desaikd closed 6 months ago

desaikd commented 11 months ago

Currently module names are hard-coded for the import statements in the generated code, this needs to be dynamic based on module path provided by user.

popematt commented 7 months ago

Having a user-provided namespace solves the problem of multiple different generated models having conflicts because they have the same namespace. However, it doesn't solve the fact that you could have something like this example where there are a total for 4 types (this one and 3 inline-imported types) that all have the same name.

type::{
  name: type_definition,
  one_of: [
    { id: "ion_schema_1_0.isl", type: type_definition },
    { id: "ion_schema_2_0.isl", type: type_definition },
    { id: "ion_schema_2_1.isl", type: type_definition },
  ]
}

We need to have schema-derived namespaces (for all languages) and the option for the user to provide a namespace root (for at least some languages).

desaikd commented 6 months ago

With the CLI option namespace for Java and single module for Rust code generation this issue is resolved: https://github.com/amazon-ion/ion-cli/pull/94