expected type, found module *** not a type
futugyou opened this issue · 3 comments
I have a struct like this, and it was working normally.
#[derive(Debug, Default, Validate, Serialize, Deserialize)]
pub struct AnimalInsertRequest {
#[serde(with = "date_format", default)]
pub rescue_date: Option<DateTime<Utc>>,
}
but when add 'JsonSchema' like this
#[derive(Debug, Default, Validate, Serialize, Deserialize, ApiComponent, JsonSchema)]
pub struct AnimalInsertRequest {
#[serde(with = "date_format", default)]
pub rescue_date: Option<DateTime<Utc>>,
}
it show an error,
error[E0573]: expected type, found module `date_format`
#[serde(with = "date_format", default)]
^^^^^^^^^^^^^ not a type
what can i do with this error
Hi, thanks for the report !
What version of apistos / schemars do you use ?
This is most likely an issue on schemars side and not directly related to apistos.
Just in case, please make sure your serde version match the one provided by schemars, it could explain the issue.
schemars = { package = "apistos-schemars", version = "0.8", features = [
"chrono",
"uuid1",
"url",
"rust_decimal",
] }
apistos = { version = "0.3", features = [
"extras",
"qs_query",
"rapidoc",
"redoc",
"swagger-ui",
] }
I also tried the default features, same error.
schemars = { package = "apistos-schemars", version = "0.8" }
apistos = { version = "0.3" }
And i found another question, this is metrics endpoint.
#[get("/metrics")]
#[api_operation(summary = "health check")]
pub(crate) async fn metrics(metrics_handle: ThinData<PrometheusHandle>) -> impl Responder {
metrics_handle.render()
}
ThinData in actix-web 4.9
PrometheusHandle in metrics-exporter-prometheus 0.15.3
this code show an error
no function or associated item named `required` found for struct `ThinData<PrometheusHandle>` in the current scope
function or associated item not found in `ThinData<PrometheusHandle>`
Hi,
I still can't figure out the issue.
About this snippet:
#[get("/metrics")] #[api_operation(summary = "health check")] pub(crate) async fn metrics(metrics_handle: ThinData<PrometheusHandle>) -> impl Responder { metrics_handle.render() }
- Apistos currently does implement
ApiComponent
forThinData
norPrometheusHandle
. It could be done and hidden behind a feature - actix macros (
#[get(...)]
for example) are currently not supported by Apistos. This would generate an incorrect definition with no path.