GithubHelp home page GithubHelp logo

netwo-io / apistos Goto Github PK

View Code? Open in Web Editor NEW
97.0 4.0 2.0 542 KB

Actix-web wrapper for automatic OpenAPI 3.0 documentation generation.

License: MIT License

Rust 99.47% HTML 0.53%
actix actix-web api openapi-documentation openapi3 rest rest-api rust

apistos's People

Contributors

axelfaure avatar boehm-s avatar gschulze avatar jayvdb avatar oss-netwo avatar rlebran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jayvdb gschulze

apistos's Issues

Incorrect Usage of ResponseWrapper Instead of ResponderWrapper

In the provided code snippet, there appears to be a typo in the usage of the type ResponseWrapper. It seems that ResponseWrapper should actually be ResponderWrapper according to the context.

Here's the corrected snippet:

if string_type == "impl Responder" {
    is_responder = true;

    *_type = Box::new(
        match syn::parse2(quote!(
            impl std::future::Future<Output=apistos::actix::ResponderWrapper<#_type>>
        )) {
            Ok(parsed) => parsed,
            Err(e) => abort!("parsing impl trait: {:?}", e),
        },
    );
}

https://github.com/netwo-io/apistos/blob/main/apistos-gen/src/internal/mod.rs#L153

No generated file on Windows

Runing the example petstore project, there are no openapi.json

PS C:\Users\User\documents\projects\apistos\examples\petstore> cargo run
info: syncing channel updates for '1.74.0-x86_64-pc-windows-msvc'
info: latest update on 2023-11-16, rust version 1.74.0 (79e9716c9 2023-11-13)```

Swagger UI for apistos like utoipa_swagger_ui

Hi.

Is it possible to use utoipa_swagger_ui (actix-web feature) with apistos, or do you have plan to implement a new one?

I tried something like this with no success:

let swagger = SwaggerUi::new("/{_:.*}").url("/openapi.json", ApiDoc::openapi()); App::new() .service(scope("/docs") .service(resource("").to(swagger)) ) .build("/openapi.json")
image

Would you like to share a suggestion?

Possibility to document successful responses.

At the moment, it seems that only error responses can be documented using #[openapi_error(...)]. It would be useful to also be able to provide a description for successful responses. Moreover, an API might return different successful responses, i.e. 200 and 201 might both be valid. Are there any plans to add this in the future?

Add support for function without any argument for the api_operation macro

Currently if I want to use the api_operation macro the following way, there is no problem:

#[api_operation(summary = "Get an element from the todo list")]
pub(crate) async fn get_todo(todo_id: Path<Uuid>) -> Result<Json<Todo>, Error> {
    // because it is a sample app, we do not currently implement any logic to store todos
    Ok(Json(Todo {
        id: todo_id.into_inner(),
        title: "some title".to_string(),
        description: None,
    }))
}

But if I want to use it like that:

#[api_operation(summary = "Get an element from the todo list")]
pub(crate) async fn get_todo() -> Result<Json<Todo>, Error> {
    // because it is a sample app, we do not currently implement any logic to store todos
    Ok(Json(Todo {
        id: Uuid::new_v4(),
        title: "some title".to_string(),
        description: None,
    }))
}

I get a compilation error:

error[E0282]: type annotations needed
  --> src/api.rs:22:1
   |
22 | #[api_operation(summary = "Get an element from the todo list")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
   |
   = note: this error originates in the macro `vec` which comes from the expansion of the attribute macro `api_operation` (in Nightly builds, run with -Z macro-backtrace for more info)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.