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

Is Box really gone in IDL 2.0? #2170

Closed
kubukoz opened this issue Mar 1, 2024 · 2 comments
Closed

Is Box really gone in IDL 2.0? #2170

kubukoz opened this issue Mar 1, 2024 · 2 comments

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Mar 1, 2024

Hi! I was under the impression @box doesn't get added in IDL 2.0. This comment on the BoxTrait class seems to confirm that:

* <p>This trait is only used in Smithy IDL 1.0 models and is not allowed in
* 2.0 models.

but it's still being added to my simple shapes in IDL 2.0:

//> using scala "2.13.10"
//> using dep "software.amazon.smithy:smithy-model:1.45.0"
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.selector.Selector
import software.amazon.smithy.model.shapes.ShapeId
import scala.jdk.CollectionConverters._
import software.amazon.smithy.model.transform.ModelTransformer
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.model.shapes.OperationShape

val r = Model
  .assembler()
  .addUnparsedModel(
    "test.smithy",
    """$version: "2"
      |namespace test
      |
      |boolean MyBoolean
      |""".stripMargin,
  )
  .assemble()
// r: software.amazon.smithy.model.validation.ValidatedResult[Model] = software.amazon.smithy.model.validation.ValidatedResult@348fda3d

val m = r.unwrap()
// m: Model = software.amazon.smithy.model.Model@ca2e6244

m.expectShape(ShapeId.from("test#MyBoolean"))
  .getAllTraits()
  .asScala
  .toList
  .map(_._1)
  .foreach(println)
// smithy.api#box

Runnable snippet here

Is this expected? (i.e. the trait is still allowed in the model, but not in the IDL) - if so, should BoxTrait even be @Deprecated?

@mtdowling
Copy link
Member

It's not allowed in IDL 2.0 models, but is a synthetic trait added to the semantic model and never serialized. It's added to the semantic model to provide a compatibility bridge between Smithy 1.0 and 2.0 for users of this library that expect a Smithy 1.0 semantic model. We marked the Java trait for box as @Deprecated to discourage people from continuing to check for it in code. Is the fact that it's marked as @Deprecated in Java causing an issue?

@kubukoz
Copy link
Contributor Author

kubukoz commented Mar 1, 2024

Nope, just wanted to clarify for the sake of knowing which traits can "reasonably" show up in a model :)

that explains it, thanks

@kubukoz kubukoz closed this as completed Mar 1, 2024
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

2 participants