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

Examples not shown with IntoResponses #779

Closed
hpsjakob opened this issue Oct 13, 2023 · 3 comments · Fixed by #1073
Closed

Examples not shown with IntoResponses #779

hpsjakob opened this issue Oct 13, 2023 · 3 comments · Fixed by #1073

Comments

@hpsjakob
Copy link

Hi,

I'm using utoipa as follows:

#[derive(IntoResponses)]
enum StandardResponses {
    #[response(status = 500, 
        content_type= "text/plain", 
        description = "Internal Error.", 
        example = json!("Internal error."))]
    InternalError,
}

#[utoipa::path(
    post,
    path = "/my_router",
    responses(StandardResponses),
    )]
pub async fn pair_device(){
  todo!()
}

This generates the following JSON output:
grafik

I'm missing the content section here. I would have expected it to be shown since I specified content_type and example.
Did I get somethign wrong or could it be that I found a bug?

I'm usign version 4.0.0.

Thank you in advance for your time!

@hpsjakob
Copy link
Author

I found that this is not the case if I change the enum to

enum StandardResponses {
    #[response(status = 500, 
        content_type= "text/plain", 
        description = "Internal Error.", 
        example = json!("Internal error."))]
    InternalError(String),
}

So I guess utoipa assumes if it's an empty enum that there's now content.

@juhaku
Copy link
Owner

juhaku commented Sep 16, 2024

@hpsjakob Yeah this is related to #965. Currently I believe as you stated that if there is no content then the content-type will not be set. This is something that needs some tuning and we should support this eventually.

@juhaku
Copy link
Owner

juhaku commented Oct 2, 2024

Yup this is a bug and finally fixed here #1073

@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban Oct 2, 2024
@juhaku juhaku moved this from Done to Released in utoipa kanban Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants