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

Cannot use derived schemas when IntOrString present #60

Open
clux opened this issue Apr 21, 2022 · 0 comments
Open

Cannot use derived schemas when IntOrString present #60

clux opened this issue Apr 21, 2022 · 0 comments

Comments

@clux
Copy link
Member

clux commented Apr 21, 2022

Minor issue when using the fully automatic schemas against something using IntOrString:

error[E0277]: the trait bound `IntOrString: JsonSchema` is not satisfied
   --> tests/./gen.rs:15:15
    |
15  |     pub port: IntOrString,
    |               ^^^^^^^^^^^ the trait `JsonSchema` is not implemented for `IntOrString`
    |
note: required by a bound in `SchemaGenerator::subschema_for`
   --> /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/schemars-0.8.8/src/gen.rs:218:38
    |
218 |     pub fn subschema_for<T: ?Sized + JsonSchema>(&mut self) -> Schema {
    |                                      ^^^^^^^^^^ required by this bound in `SchemaGenerator::subschema_for`

error[E0277]: the trait bound `IntOrString: JsonSchema` is not satisfied
 --> tests/./gen.rs:7:64
  |
7 | #[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
  |                                                                ^^^^^^^^^^ the trait `JsonSchema` is not implemented for `IntOrString`
  |
  = note: this error originates in the derive macro `JsonSchema` (in Nightly builds, run with -Z macro-backtrace for more info)

some potential solutions:

  • get an impl in k8s-openapi
  • inline IntOrString with JsonSchema derive (awkward, but avoids user dep on k8s-openapi in some cases perhaps)

This isn't a big deal because it's only the schema part, we can still generate the structs.

Workaround is not use -A or --schema=derived with such schemas, but use --schema=manual or the default and read the schema from a file if needed (if you need to overwrite the crd at some point).

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

No branches or pull requests

1 participant