Skip to content

Conversation

@ahl
Copy link
Collaborator

@ahl ahl commented Jan 7, 2022

This structures the parameters to the generate_api! macro (incompatibly) and allows for extra derive macros such as JsonSchema.

---8<--- old ---8<---

@smklein let me know if this works for you

I'm going to poke at two things

  1. typify and progenitor optional user input for derive macros (it's tricky if we want to / need to be selective about the types to which these derives can be applied; maybe I'll make an unstable interface for this
  2. progenitor emitting a dropshot server stub; I don't think it might be relatively easy given the IR we already have for operations

@smklein
Copy link

smklein commented Jan 7, 2022

First attempt at integrating (just adding a "Cargo.toml" patch for progenitor to use this branch):

error[E0432]: unresolved import `schemars`
 --> agent-client/src/lib.rs:5:1
  |
5 | generate_api!("../openapi/crucible-agent.json");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `schemars`
  |
  = note: this error originates in the macro `generate_api` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot determine resolution for the derive macro `JsonSchema`
 --> agent-client/src/lib.rs:5:1
  |
5 | generate_api!("../openapi/crucible-agent.json");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports
  = note: this error originates in the macro `generate_api` (in Nightly builds, run with -Z macro-backtrace for more info)

I think the issue is that the "FOO-client" crates don't depend on schemars, but they would need to for this PR to work correctly.

I can go add that dependency (manually) and try once more.

@smklein
Copy link

smklein commented Jan 7, 2022

Adding the schemars dependencies, this seems to work! I'll upload branches shortly.

@smklein
Copy link

smklein commented Jan 7, 2022

The two linked PRs show the necessary changes. I would have used cargo patch to point to this branch, but that doesn't seem possible due to rust-lang/cargo#5478. In the meantime, I just patched with local files to show what changes are incurred.

structured generate_api! macro
general updates and cleanup
@ahl ahl changed the title JsonSchema branch Allow consumers to specify additional derive macros for generated types Jan 13, 2022
@ahl ahl marked this pull request as ready for review January 13, 2022 23:10
@ahl ahl merged commit aff25f2 into main Jan 15, 2022
@ahl ahl deleted the json-schema branch January 15, 2022 02:02
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

Successfully merging this pull request may close these issues.

3 participants