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

#[serde(rename = "_")] #201

Open
HHogg opened this issue Oct 3, 2024 · 1 comment
Open

#[serde(rename = "_")] #201

HHogg opened this issue Oct 3, 2024 · 1 comment

Comments

@HHogg
Copy link

HHogg commented Oct 3, 2024

#[derive(Serialize)]
#[serde(rename = "SomethingFoo")]
#[typeshare]
pub enum Foo {
  A  
}

#[derive(Serialize)]
#[typeshare]
#[serde(tag = "type", content = "value")]
pub enum Parent {
  B(Foo),
}

Outputs

export enum SomethingFoo = { A =  'A' }

export type Parent = { type: 'B', value: Foo  } // No Foo. Only SomethingFoo
@darrell-roberts
Copy link
Member

I have a WIP solution for this: #210.

Are you using the multiple file output option? If your outputting to a single file this approach works, however in the case of multiple files it assumes, at the moment, your renamed type and reference are both in the same crate scope.

Would you be able to try this out and let me know if it covers your use cases? I created this snapshot test which adds additional reference use cases.

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