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

Auto schema collection for params #1165

Open
dittos opened this issue Oct 25, 2024 · 1 comment
Open

Auto schema collection for params #1165

dittos opened this issue Oct 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dittos
Copy link

dittos commented Oct 25, 2024

Auto schema collection added in utoipa 5 is really nice! 👍
However it seems that schema in params are not collected. Is it just not implemented yet or not included intentionally?

use utoipa::{IntoParams, OpenApi, ToSchema};

#[derive(ToSchema)]
enum EnumValue {
    Apple,
    Orange,
}

#[derive(IntoParams)]
struct Params {
    x: EnumValue,
}

#[utoipa::path(
    get,
    path = "",
    params(
        ("value" = EnumValue, Query),
        Params,
    ),
)]
fn handler() {}

#[derive(OpenApi)]
#[openapi(
    paths(handler)
)]
struct Api;

fn main() {
    println!("{}", serde_json::to_string_pretty(&Api::openapi()).unwrap());
}

Generates the following without EnumValue in components.

{
  "openapi": "3.1.0",
  "info": {
    "title": "utoipa-bug",
    "description": "",
    "license": {
      "name": ""
    },
    "version": "0.1.0"
  },
  "paths": {
    "": {
      "get": {
        "tags": [],
        "operationId": "handler",
        "parameters": [
          {
            "name": "value",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/EnumValue"
            }
          },
          {
            "name": "x",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/EnumValue"
            }
          }
        ],
        "responses": {}
      }
    }
  },
  "components": {} // <--
}
@juhaku
Copy link
Owner

juhaku commented Oct 25, 2024

However it seems that schema in params are not collected. Is it just not implemented yet or not included intentionally?

It was not implemented by design and party forgotten. This is something that need to be addressed in future.

@juhaku juhaku added the enhancement New feature or request label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants