Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expected type, found module *** not a type #129

Open
futugyou opened this issue Sep 3, 2024 · 3 comments
Open

expected type, found module *** not a type #129

futugyou opened this issue Sep 3, 2024 · 3 comments

Comments

@futugyou
Copy link

futugyou commented Sep 3, 2024

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

@rlebran
Copy link
Contributor

rlebran commented Sep 5, 2024

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.

@futugyou
Copy link
Author

futugyou commented Sep 5, 2024

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",
] }

Reference here

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>`

@rlebran
Copy link
Contributor

rlebran commented Sep 24, 2024

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 for ThinData nor PrometheusHandle. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants