Apistos

An OpenAPI documentation tool exposing OAS 3.0 models as well as an actix-web wrapper similar to paperclip.
Apistos is composed of these crates:
apistos: actix-web wrapper to generate an OpenAPI v3.0.3 documentation fileapistos-core: A set of traits and common models around OpenAPI v3.0.3apistos-gen: macro utilities to generate OpenAPI v3.0.3 documentation from Rust modelsapistos-models: OpenAPI v3.0.3 models withSchemabased on schemars definitionapistos-plugins: traits and utilities to extend apistosapistos-rapidoc: bridge between Apistos and RapiDoc for actix.apistos-plugins: bridge between Apistos and Redoc for actix.apistos-scalar: bridge between Apistos and Scalar for actix.apistos-shuttle: allows you to run an actix-web server documented with Apistos on Shuttle.apistos-swagger-ui: bridge between Apistos and Swagger UI for actix
Check out our example project.
What does Apistos means
Apistos (pronounced /a.p.i.stos/) is a word play between Héphaïstos (Ἥφαιστος, grec god of blacksmiths, carpenters, craftsmen, metallurgy ... which can also be considered by some as the god of technology) and API (pronounced /a.p.i/ in French).
Apistos
Installation
[]
#schemars = "0.8"
# sadly we currently rely on a fork to fix multiple flatten for enums, related PR can be found here: https://github.com/GREsau/schemars/pull/264
= { = "apistos-schemars", = "0.8" }
= "0.6"
Usage example
Wrap your regular actix-web app using apistos types.
Most of these types are drop-in types for actix-web one's.
use Display;
use ;
use StatusCode;
use Logger;
use Json;
use CreatedJson;
use api_operation;
use ApiComponent;
use ApiErrorComponent;
use OpenApiWrapper;
use Spec;
use ;
use Info;
use Formatter;
use JsonSchema;
use ;
use Error;
use Ipv4Addr;
pub async
async
For a complete example, see the sample petstore.
Feature flags
| name | description | extra dependencies |
|---|---|---|
query (default) |
Enables documenting actix_web::web::Query |
|
actix (default) |
Enables documenting types from actix |
|
lab_query |
Enables documenting actix_web_lab::extract::Query |
actix-web-lab |
garde |
Enables input validation through garde |
garde |
actix-session |
Enables documenting types from actix-session |
actix-session |
actix-web-grants |
Enables support for actix-web-grants |
actix-web-grants |
rapidoc |
Enables RapiDoc to expose the generated openapi file | |
redoc |
Enables Redoc to expose the generated openapi file | |
swagger-ui |
Enables Swagger UI to expose the generated openapi file | |
qs_query |
Enables documenting types from serde_qs |
serde_qs |
chrono |
Enables documenting types from chrono |
chrono |
multipart |
Enables documenting types from actix-multipart |
actix-multipart |
rust_decimal |
Enables documenting types from rust_decimal |
rust_decimal |
uuid |
Enables documenting types from uuid |
uuid |
url |
Enables documenting types from url |
url |
extras |
Enables chrono, multipart, rust_decimal, uuid and url features |
All from previous features |
What's next
- Handle schema for errors using ApiErrorComponent derive macro
Alternatives
| Crate | Key differences |
|---|---|
paperclip |
Paperclip is similar to this project but generates Swagger v2 documentation. Paperclip also provides a tool to generate rust code from a Swagger v2 document. |
utoipa |
Utoipa-actix integration rely on actix web macros for routing definition. At first, we planned on relying on utoipa for OAS types and schema derivation but for now utoipa doesn't support generic struct the way we intended to. |
okapi |
Pretty similar, based on schemars as well (and maintained by the founder of schemars) but not integrated with actix. |
Articles
- announcement article can be found on medium. It acts as a tutorial for Apistos.
About us
apistos is provided by Netwo.
We use this crate for our internal needs and therefore are committed to its maintenance, however we cannot provide any additional guaranty. Use it at your own risks.
While we won't invest in any feature we don't need, we are open to accept any pull request you might propose.
We are a France based full-remote company operating in the telecom industry. If you are interested in learning more, feel free to visit our career page.