netwo-io / apistos Goto Github PK
View Code? Open in Web Editor NEWActix-web wrapper for automatic OpenAPI 3.0 documentation generation.
License: MIT License
Actix-web wrapper for automatic OpenAPI 3.0 documentation generation.
License: MIT License
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
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)```
Just to keep track of the fact that we should definitely use the original schemars in our dependencies as soon as GREsau/schemars#264 is merged
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")
Would you like to share a suggestion?
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?
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)
We should check what would be needed to support OAS 3.1 instead of 3.0 and possibly plan that.
Hi,
I would like to use this crate in a shuttle.rs environment.
As you can see on the following link, in a shuttle based actix-web application you dont have access to the actix web app sturct directly.
Is there anyway to use this crate through service configuration?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.