hsr

Build fast HTTP APIs fast, with Rust + OpenAPI


Keywords
web, openapi, actix-web, rest, swagger
License
MIT

Documentation

HSR

Build fast HTTP apis fast, with Rust, and OpenAPI

  • Define your API as an OpenAPI 3.0 spec
  • Code-gen a server/client interface (based on actix-web)
  • Implement your interface (simple, safe, strongly typed!)
  • Run! 'If it compiles, it works'

Quickstart

Take a look at the quickstart repo. It contains the minimum boilerplate needed to get started.

Less quick start

Take a look at the petstore repo for a more in-depth example.

Roadmap

  • HTTP server
  • HTTP client
  • Type-safe path/query/json handling
  • High performance
  • HTTPS
  • Benchmarks
  • Return content-types other than JSON
  • AnyOf/OneOf schema support
  • Support all features necessary to get petstore-expanded.yaml working
  • Support headers
  • (Once the futures ecosystem has matured) - move away from futures v1
  • Option to use existential types
  • Advanced server configuration (with middleware etc)
  • Even less boilerplate
  • Works on stable Rust
  • JSON schema
  • Tutorial

FAQ

What's the difference between this and swagger-rs?

  • swagger-rs is a more mature projuect with institutional backing.
  • It uses futures v0.1 throughout - hsr attempts to use futures v0.3 to allow async/await syntax
    • Consequently - it works on stable, hsr requires nightly
  • Requires the codegenerator, written in Java - hsr is 100% Rust
    • That means that the swagger-rs code generator is likely much more correct...
    • ..but the hsr build process is much more seamlessly integrated into typical Rust workflow
  • Error-handling story somewhat different
  • Surely lots of other differences

What do you mean, 'fast'?

It uses Actix-Web under the hood, rated as one of the fastest web frameworks by techempower.

No benchmarks yet.

Why the name?

I like fast trains.

License

MIT