pub trait IntoParams {
    // Required method
    fn into_params(
        parameter_in_provider: impl Fn() -> Option<ParameterIn>
    ) -> Vec<Parameter>;
}
Expand description

Trait used to convert implementing type to OpenAPI parameters.

This trait is derivable for structs which are used to describe path or query parameters. For more details of #[derive(IntoParams)] refer to derive documentation.

Examples

Derive IntoParams implementation. This example will fail to compile because IntoParams cannot be used alone and it need to be used together with endpoint using the params as well. See derive documentation for more details.

use utoipa::{IntoParams};

#[derive(IntoParams)]
struct PetParams {
    /// Id of pet
    id: i64,
    /// Name of pet
    name: String,
}

Roughly equal manual implementation of IntoParams trait.

impl utoipa::IntoParams for PetParams {
    fn into_params(
        parameter_in_provider: impl Fn() -> Option<utoipa::openapi::path::ParameterIn>
    ) -> Vec<utoipa::openapi::path::Parameter> {
        vec![
            utoipa::openapi::path::ParameterBuilder::new()
                .name("id")
                .required(utoipa::openapi::Required::True)
                .parameter_in(parameter_in_provider().unwrap_or_default())
                .description(Some("Id of pet"))
                .schema(Some(
                    utoipa::openapi::ObjectBuilder::new()
                        .schema_type(utoipa::openapi::SchemaType::Integer)
                        .format(Some(utoipa::openapi::SchemaFormat::KnownFormat(utoipa::openapi::KnownFormat::Int64))),
                ))
                .build(),
            utoipa::openapi::path::ParameterBuilder::new()
                .name("name")
                .required(utoipa::openapi::Required::True)
                .parameter_in(parameter_in_provider().unwrap_or_default())
                .description(Some("Name of pet"))
                .schema(Some(
                    utoipa::openapi::ObjectBuilder::new()
                        .schema_type(utoipa::openapi::SchemaType::String),
                ))
                .build(),
        ]
    }
}

Required Methods§

fn into_params( parameter_in_provider: impl Fn() -> Option<ParameterIn> ) -> Vec<Parameter>

Provide Vec of [openapi::path::Parameter]s to caller. The result is used in utoipa-gen library to provide OpenAPI parameter information for the endpoint using the parameters.

Object Safety§

This trait is not object safe.

Implementors§

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::flight_plan::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::flight_plan::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::flight_plan::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::flight_plan::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::flight_plan::UpdateObject

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::group::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::group::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::group::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::group::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::group::UpdateObject

§

impl IntoParams for FieldValue

§

impl IntoParams for Id

§

impl IntoParams for IdList

§

impl IntoParams for ValidationError

§

impl IntoParams for ValidationResult

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::user::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::user::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::user::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::user::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::user::UpdateObject

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vehicle::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vehicle::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vehicle::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vehicle::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vehicle::UpdateObject

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertipad::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertipad::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertipad::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertipad::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertipad::UpdateObject

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertiport::Data

§

impl IntoParams for GeoLine

§

impl IntoParams for GeoLineString

§

impl IntoParams for GeoPoint

§

impl IntoParams for GeoPolygon

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertiport::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertiport::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertiport::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::vertiport::UpdateObject

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::itinerary::Data

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::itinerary::List

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::itinerary::Object

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::itinerary::Response

§

impl IntoParams for svc_scheduler_client_grpc::prelude::scheduler_storage::itinerary::UpdateObject