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

Pass ParsePayload<T>::IS_REQUIRED to T instead of defaulting to …true #932

Merged

Conversation

Nahuel-M
Copy link
Contributor

Currently, it's impossible to request or respond with an optional Json body.
Example:

 #[oai(path = "/opa", method = "get")]
    pub async fn get(&self, Json(test): Json<Option<Klaboom>>) -> Json<String> {
        Json("Hello, world!".to_string())
    }

expands to openapi:

"/opa": {
      "get": {
        "requestBody": {
          "content": {
            "application/json; charset=utf-8": {
              "schema": {
                "$ref": "#/components/schemas/Klaboom"
              }
            }
          },
          "required": true
        },
 ...
}

This PR passes the IS_REQUIRED field to the child T, which solves this.

@sunli829 sunli829 merged commit 3818a19 into poem-web:master Dec 18, 2024
7 checks passed
@Nahuel-M Nahuel-M deleted the poem-openapi-json-payload-required branch December 20, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants