12 releases (6 breaking)

0.7.0 Oct 13, 2024
0.6.3 Aug 20, 2023
0.6.2 Jan 14, 2023
0.6.1 Jul 27, 2022
0.2.0 Jul 30, 2019

#1054 in Procedural macros

Download history 3171/week @ 2024-07-02 3049/week @ 2024-07-09 3825/week @ 2024-07-16 2644/week @ 2024-07-23 3152/week @ 2024-07-30 2637/week @ 2024-08-06 2310/week @ 2024-08-13 2294/week @ 2024-08-20 2538/week @ 2024-08-27 3781/week @ 2024-09-03 3766/week @ 2024-09-10 3384/week @ 2024-09-17 3991/week @ 2024-09-24 2534/week @ 2024-10-01 3120/week @ 2024-10-08 4226/week @ 2024-10-15

14,572 downloads per month
Used in 10 crates (3 directly)

MIT/Apache

97KB
2K SLoC

Paperclip

Build Status Linter Status Usage docs API docs Crates.io

Paperclip offers tooling for the OpenAPI specification. Once complete, it will provide:

  • Code generation for efficient, type-safe, compile-time checked HTTP APIs (server, client and CLI) in Rust.
  • Support for processing, validating and hosting OpenAPI spec.
  • Customization for spec and code generation.

It's currently under active development and may not be ready for production use just yet.

You may be interested in:

Developing locally

  • Clone the repository along with its submodules using the following command:

     git clone --recurse-submodules git@github.com:paperclip-rs/paperclip.git
    
  • Make sure you have rustup installed.

  • Then move to repository:

    cd paperclip
    
  • Run the setup environment routine

    make prepare
    
  • Build the project and run tests:

    make
    

Contributing

This project welcomes all kinds of contributions. No contribution is too small!

If you want to contribute to this project but don't know how to begin or if you need help with something related to this project, feel free to send me an email (in Github profile) or join the Discord server.

Code of Conduct

This project follows the Rust Code of Conduct.

License

Licensed under either of

at your option.

Sponsors

Folks who have sponsored for the development of this project:

FAQ

Why is this generating raw Rust code instead of leveraging procedural macros for compile-time codegen?

I don't think proc macros are the right way to go for REST APIs. We need to be able to see the generated code somehow to identify names, fields, supported methods, etc. With proc macros, you sorta have to guess.

This doesn't mean you can't generate APIs in compile-time. The only difference is that you'll be using build scripts instead and include! the relevant code. That said, we're using proc-macros for other things.

The error thrown at compile-time doesn't look like it's very useful. Isn't there a better way to do this?

None that I can think of, sadly.

New ideas are here needed.


lib.rs:

Convenience macros for paperclip.

You shouldn't need to depend on this, because the stuff here is already exposed by the corresponding crates.

Dependencies

~1.5MB
~40K SLoC