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

no_recursion with HasMap not working #1166

Closed
fospitia opened this issue Oct 26, 2024 · 1 comment · Fixed by #1167
Closed

no_recursion with HasMap not working #1166

fospitia opened this issue Oct 26, 2024 · 1 comment · Fixed by #1167
Labels
bug Something isn't working

Comments

@fospitia
Copy link

Hi.

Next code fails with stack overflow

#[derive(Serialize, Deserialize, ToSchema)]
#[schema(no_recursion)]
pub struct Tree {
    left: Box<Tree>,
    right: Box<Tree>,
}

#[derive(Serialize, Deserialize, ToSchema)]
#[schema(no_recursion)]
pub enum TreeRecursion {
    Named { left: Box<TreeRecursion> },
    Unnamed(Box<TreeRecursion>),
    NoValue,
}

#[derive(Serialize, Deserialize, ToSchema)]
pub enum Recursion {
    #[schema(no_recursion)]
    Named {
        left: Box<Recursion>,
        right: Box<Recursion>,
    },
    #[schema(no_recursion)]
    Unnamed(Box<Recursion>),
    Map(HashMap<String, Recursion>),
    NoValue,
}

Without the Map(HashMap<String, Recursion>) line work.

And if you add it, the macro gives the following error

    #[schema(no_recursion)]
    Map(HashMap<String, Recursion>),
NoRecursion does not support `ToTokens`

Thanks

@juhaku
Copy link
Owner

juhaku commented Oct 26, 2024

Oh, that is a bug indeed,

   #[schema(no_recursion)]
    Map(HashMap<String, Recursion>),

The above should be possible.

@juhaku juhaku added the bug Something isn't working label Oct 26, 2024
@juhaku juhaku moved this to Todo in utoipa kanban Oct 26, 2024
@juhaku juhaku moved this from Todo to In Progress in utoipa kanban Oct 27, 2024
juhaku added a commit that referenced this issue Oct 27, 2024
This commit fixes `no_recursion` attribute on map types like
`HashMap<K, T>`.

Fixes #1166
juhaku added a commit that referenced this issue Oct 27, 2024
This commit fixes `no_recursion` attribute on map types like
`HashMap<K, T>`.

Fixes #1166
@juhaku juhaku closed this as completed in 542800b Oct 27, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban Oct 27, 2024
@juhaku juhaku moved this from Done to Released in utoipa kanban Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants