Derive Macro apistos::ApiType

source ยท
#[derive(ApiType)]
Expand description

Generates a custom OpenAPI type.

This #[derive] macro should be used in combination with TypedSchema.

When deriving ApiType, ApiComponent and JsonSchema are automatically implemented and thus should not be derived.

use apistos::{ApiType, InstanceType, TypedSchema};

#[derive(Debug, Clone, ApiType)]
pub struct Name(String);

impl TypedSchema for Name {
  fn schema_type() -> InstanceType {
    InstanceType::String
  }

  fn format() -> Option<String> {
    None
  }
}