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

Union members targeting smithy.api#Unit generates extraneous structures #1040

Open
aajtodd opened this issue Feb 20, 2024 · 1 comment
Open
Assignees
Labels
bug This issue is a bug. no-auto-closure We do not want this issue to be automatically closed. p2 This is a standard priority issue

Comments

@aajtodd
Copy link
Contributor

aajtodd commented Feb 20, 2024

The smithy.api#Unit type can only be targeted by operation inputs/outputs or as a member of union shape. Inputs and outputs always get type defined even if the operation targeted unit (this is in part because unit support came later but also so that if a service wants to add members to a request/response they can do so in a backwards compatible way).

union Foo {
    stringType: String,
    unitType: Unit
}

Currently we seem to be generating a backing structure for union types

sealed class Foo {
    class StringType(val value: String): Foo()
    class UnitType(val value: Unit): Foo()
}

class Unit { ... }

We most likely just want to generate a variant with no members, e.g.:

sealed class Foo {
    class StringType(val value: String): Foo()
    object UnitType: Foo()
}

Want to confirm that there are no current unions targeting a unit member before changing this.

@aajtodd aajtodd added the bug This issue is a bug. label Feb 20, 2024
@ianbotsf ianbotsf added the p2 This is a standard priority issue label Apr 4, 2024
@lauzadis lauzadis self-assigned this Apr 8, 2024
@lauzadis
Copy link
Contributor

lauzadis commented Apr 8, 2024

confirmed no current unions target a unit member: smithy select --allow-unknown-traits --selector "union > member > [trait|smithy.api#unitType]" ./*.json

@ianbotsf ianbotsf added the no-auto-closure We do not want this issue to be automatically closed. label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. no-auto-closure We do not want this issue to be automatically closed. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants