poem icon indicating copy to clipboard operation
poem copied to clipboard

Object with serde_json::Value property doesn't show good example in UI

Open xrl opened this issue 1 year ago • 1 comments

Expected Behavior

My API accepts arbitrary JSON:


#[derive(Object, Debug)]
pub struct BulkRequestDoc {
    pub smile: String,
    pub extra_data: Option<serde_json::Value>,
}

which should produce example data like:

{
  "docs": [
    {
      "smile": "string",
      "extra_data": {}
    }
  ]

Actual Behavior

but the extra_data field renders in the UI as:

{
  "docs": [
    {
      "smile": "string",
      "extra_data": "string"
    }
  ]
image

Steps to Reproduce the Problem

  1. Object definition like
#[derive(Object, Debug)]
pub struct BulkRequestDoc {
    pub smile: String,
    pub extra_data: Option<serde_json::Value>,
}

Render web ui with

    let ui = api_service.swagger_ui();
    // SNIP
                .nest("/", ui)

Specifications

  • Version: 2.0.27
  • Platform: OS X
  • Subsystem: poem-openapi-derive (presumably)

xrl avatar Oct 18 '23 20:10 xrl

I suppose I want to somehow enforce that the root value of extra_data is a serde_json::Value::Object. Anyone done that?

xrl avatar Oct 18 '23 20:10 xrl