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

Unable to collect schemas recursively when using tuples #1257

Open
MitsuPa opened this issue Dec 26, 2024 · 1 comment
Open

Unable to collect schemas recursively when using tuples #1257

MitsuPa opened this issue Dec 26, 2024 · 1 comment
Labels
investigate Futher investigation needed before other action

Comments

@MitsuPa
Copy link

MitsuPa commented Dec 26, 2024

#[derive(ToSchema, Serialize, Deserialize)]
struct B {
  test: String,
}

#[derive(ToSchema, Serialize, Deserialize)]
struct A {
  b: B,
}

#[utoipa::path(
  method(post),
  request_body(
    content = (A, String)
  ),
  path = "/test",
  responses(
      (status = OK, body = (A, String))
  ),
  tag = "statistics",
)]
async fn get_statistics(Json(req): Json<(A, String)>) -> Json<(A, String)> {
  print!("{:?}", req.1);
  Json((req.0, req.1))
}

Could not resolve reference: JSON Pointer evaluation failed while evaluating token "B" against an ObjectElement

        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": false,
                "prefixItems": [
                  {
                    "type": "object",
                    "required": [
                      "b"
                    ],
                    "properties": {
                      "b": {
                        "$ref": "#/components/schemas/B"
                      }
                    }
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            }
          },

No B in #/components/schemas/

Please check it, thank you very much!

@juhaku juhaku added the investigate Futher investigation needed before other action label Jan 2, 2025
@juhaku
Copy link
Owner

juhaku commented Jan 2, 2025

Probably a bug somewhere in automatic schema collection which does not take account all the types of tuples when collecting the schemas with tuples. This indeed needs some investigation for to find the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Futher investigation needed before other action
Projects
None yet
Development

No branches or pull requests

2 participants