GREsau / okapi

OpenAPI (AKA Swagger) document generation for Rust projects
MIT License
578 stars 103 forks source link

Conflict with kube-rs when importing rocket-okapi #109

Closed korewaChino closed 1 year ago

korewaChino commented 2 years ago
error[E0308]: mismatched types
  --> /home/cappy/.cargo/registry/src/github.com-1ecc6299db9ec823/kube-core-0.74.0/src/schema.rs:68:29
   |
67 |                         match common_obj.properties.entry(property_name) {
   |                               ------------------------------------------ this expression has type `indexmap::map::core::Entry<'_, std::string::String, schemars::schema::Schema>`
68 |                             Entry::Occupied(entry) => panic!(
   |                             ^^^^^^^^^^^^^^^^^^^^^^ expected enum `indexmap::map::core::Entry`, found enum `std::collections::btree_map::Entry`
   |
   = note: expected enum `indexmap::map::core::Entry<'_, std::string::String, schemars::schema::Schema>`
              found enum `std::collections::btree_map::Entry<'_, _, _>`

error[E0308]: mismatched types
  --> /home/cappy/.cargo/registry/src/github.com-1ecc6299db9ec823/kube-core-0.74.0/src/schema.rs:72:29
   |
67 |                         match common_obj.properties.entry(property_name) {
   |                               ------------------------------------------ this expression has type `indexmap::map::core::Entry<'_, std::string::String, schemars::schema::Schema>`
...
72 |                             Entry::Vacant(entry) => {
   |                             ^^^^^^^^^^^^^^^^^^^^ expected enum `indexmap::map::core::Entry`, found enum `std::collections::btree_map::Entry`
   |
   = note: expected enum `indexmap::map::core::Entry<'_, std::string::String, schemars::schema::Schema>`
              found enum `std::collections::btree_map::Entry<'_, _, _>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `kube-core` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
ralpha commented 1 year ago

This is a problem with kube-core. They hard code the type in there schema.rs file. But this type changes with the preserve_order flag in schemars.

This line: https://github.com/kube-rs/kube/blob/b92dc5ba25b0ab91c979b0dfe5cb9306ba157def/kube-core/src/schema.rs#L5

Should be changed to:

use schemars::MapEntry as Entry;

or just use schemars::MapEntry; and change the match lower down in the code (line 104-114).

ralpha commented 1 year ago

Transferred issue to kube-rs. https://github.com/kube-rs/kube/issues/1049

Thanks for reporting. I'll close the issue here.