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

Union doesn't implement IsObjectType #800

Open
vpikulik opened this issue Apr 12, 2024 · 1 comment
Open

Union doesn't implement IsObjectType #800

vpikulik opened this issue Apr 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@vpikulik
Copy link

Expected Behavior

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 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?

@DDtKey
Copy link
Contributor

DDtKey commented May 24, 2024

I guess it can be closed now as well as #799?
Thank you @sunli829 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants