Skip to content

Conversation

DanielleHuisman
Copy link

Schema

#[derive(ToSchema)]
struct Top {
    bounds: Bounds<i32>,
}

#[derive(ToSchema)]
struct Bounds<T> {
    min: Option<T>,
}

Current behaviour
The Bounds_i32 schema lists min as a non-nullable integer.

{
  "components": {
    "schemas": {
      "Bounds_i32": {
        "type": "object",
        "properties": {
          "min": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "Top": {
        "type": "object",
        "required": [
          "bounds"
        ],
        "properties": {
          "bounds": {
            "$ref": "#/components/schemas/Bounds_i32"
          }
        }
      }
    }
  }
}

Expected behaviour
The Bounds_i32 schema should list min as a nullable integer.

{
  "components": {
    "schemas": {
      "Bounds_i32": {
        "type": "object",
        "properties": {
          "min": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "integer",
                "format": "int32"
              }
            ]
          }
        }
      },
      "Top": {
        "type": "object",
        "required": [
          "bounds"
        ],
        "properties": {
          "bounds": {
            "$ref": "#/components/schemas/Bounds_i32"
          }
        }
      }
    }
  }
}

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.

1 participant