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

Allow alias for serde_json::Value: Gobal Rusts Type Alias registry #766

Open
JoverZhang opened this issue Sep 19, 2023 · 1 comment
Open

Comments

@JoverZhang
Copy link

Hello.

Instead of using serde_json::Value directly, we added an alias Json for serde_json::Value.

But the Json won't be recognized as serde_json::Value.

pub type Json = serde_json::Value;

This would make it recognizable, but that doesn't make much sense.

pub struct VO {
  #[schema(value_type = HashMap<String, serde_json::Value>)]
  pub fields: HashMap<String, Json>,
}

Could it be like #[aliases], where to write it once, and it's consistently recognized as serde_json::Value?

@juhaku
Copy link
Owner

juhaku commented Nov 8, 2023

Could it be like #[aliases], where to write it once, and it's consistently recognized as serde_json::Value?

Unfortunately this is not possible at the moment. This needs a global registry for the type aliases that is available for the macro compile process. This would need some experimenting in order to find the right solution. This is not straight forward to implement to my reckoning, yet the support would be quite beneficial for the library and the users. Definitely something that can be investigated in future.

@juhaku juhaku changed the title Allow alias for serde_json::Value Allow alias for serde_json::Value: Gobal Rusts Type Alias registry Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants