Skip to content

Dealing with type aliases #343

Answered by juhaku
kdallasd asked this question in Q&A
Nov 10, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Yeah, type aliases are a bit tricky topic and the reason being is as you said Rust does not allow derive macros (nor traits to be implemented for) to be used with type aliases. This evidently gives users three choices with how things currently work.

  1. Is to continue to use the #[schema(value_type = ...)] you have already used.
  2. Use Rust new type pattern.
  3. Define the type manually to the OpenApi struct. Either with Modify trait or though builders.

Both of 1. and 2. them has advantages and disadvantages. For what comes to the new type pattern Rust compiler will remove the unnecessary layer of abstraction at compile time which leads to no extra cost in compiled application. Since it is a new t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kdallasd
Comment options

Answer selected by kdallasd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants