poem icon indicating copy to clipboard operation
poem copied to clipboard

Union doesn't implement `IsObjectType`

Open vpikulik opened this issue 10 months ago • 1 comments

Expected Behavior

https://github.com/poem-web/poem/compare/master...vpikulik:poem:union_is_object_type

Actual Behavior

$ -> cargo check
    Checking example-openapi-union v0.1.0 (/Users/promo/wd/poem/examples/openapi/union)
error[E0277]: the trait bound `MyObj: IsObjectType` is not satisfied
  --> openapi/union/src/main.rs:25:8
   |
25 |     My(MyObj),
   |        ^^^^^ the trait `IsObjectType` is not implemented for `MyObj`
   |
   = help: the following other types implement trait `IsObjectType`:
             A
             B
note: required by a bound in `<TopObj as Type>::register::{closure#0}::_::{closure#0}::assert_impl_all`
  --> openapi/union/src/main.rs:22:10
   |
22 | #[derive(Union, Debug, PartialEq)]
   |          ^^^^^ required by this bound in `assert_impl_all`
   = note: this error originates in the macro `poem_openapi::__private::static_assertions::assert_impl_all` which comes from the expansion of the derive macro `Union` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `example-openapi-union` (bin "example-openapi-union") due to 1 previous error

Steps to Reproduce the Problem

  1. switch to https://github.com/poem-web/poem/compare/master...vpikulik:poem:union_is_object_type
  2. cd poem/examples/openapi/union
  3. cargo check

Specifications

  • Version: rustc 1.77.2
  • Platform:
  • Subsystem:

How to solve

impl IsObjectType for MyObj {} solves the problem Should it be added to Union derive macro?

vpikulik avatar Apr 12 '24 08:04 vpikulik