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

description missing when mixing inline + user-defined type #797

Closed
JMLX42 opened this issue Nov 9, 2023 · 2 comments · Fixed by #1102
Closed

description missing when mixing inline + user-defined type #797

JMLX42 opened this issue Nov 9, 2023 · 2 comments · Fixed by #1102

Comments

@JMLX42
Copy link
Contributor

JMLX42 commented Nov 9, 2023

How to reproduce

utoipa version 4.0.0

    #[schema(as = BufferResourceIdentifierObject)]
    pub struct BufferResourceIdentifierObject {
        #[serde(rename = "type")]
        #[schema(default = "buffers")]
        type_name: String,
        id: uuid::Uuid,
    }

    pub struct BufferResourceRelationshipToOne {
        #[schema(inline)]
        pub data: BufferResourceIdentifierObject,
    }

   #[serde(rename_all = "camelCase")]
    pub struct BufferViewResourceSparseRelationships {
        #[serde(default, skip_serializing_if = "Option::is_none")]
        #[schema(inline)]
        /// The index of the buffer.
        pub buffer: Option<crate::buffer::BufferResourceRelationshipToOne>,
    }

Actual Result

For some reason, the description field is missing.

{
  "relationships": {
    "type": "object",
    "properties": {
      "buffer": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "data"
            ],
            "properties": {
              "data": {
                "type": "object",
                "required": [
                  "type",
                  "id"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "default": "buffers"
                  },
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        ],
        "nullable": true
      }
    }
  }
}

Expected Result

{
  "relationships": {
    "type": "object",
    "properties": {
      "buffer": {
        "allOf": [
          {
            "description": "The index of the buffer.",
            "type": "object",
            "required": [
              "data"
            ],
@juhaku
Copy link
Owner

juhaku commented Nov 12, 2023

This probably hits a scenario that does not fully support all the fields. Thanks for reporting with actual example this will make the further investigation easier when begin.

juhaku added a commit that referenced this issue Oct 7, 2024
This commit fixes the missing description on inlined field items by
making field `allOf` with `description` in presence of description.

Fixes #797
juhaku added a commit that referenced this issue Oct 7, 2024
This commit fixes the missing description on inlined field items by
making field `allOf` with `description` in presence of description.

Fixes #797
@juhaku juhaku moved this to In Progress in utoipa kanban Oct 7, 2024
@juhaku
Copy link
Owner

juhaku commented Oct 7, 2024

Fix is coming in PR #1102

juhaku added a commit that referenced this issue Oct 7, 2024
This commit fixes the missing description on inlined field items by
making field `allOf` with `description` in presence of description.

Fixes #797
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban Oct 7, 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