Derive Macro apistos::ApiHeader

source ·
#[derive(ApiHeader)]
{
    // Attributes available to this derive:
    #[openapi_header]
}
Expand description

Generates a reusable OpenAPI header schema.

This #[derive] macro should be used in combination with api_operation. The macro requires one and only one openapi_header.

This macro requires your type to derive JsonSchema.

use apistos::ApiHeader;
use schemars::JsonSchema;

#[derive(Debug, Clone, JsonSchema, ApiHeader)]
#[openapi_header(
  name = "X-Organization-Slug",
  description = "Organization of the current caller",
  required = true
)]
pub struct OrganizationSlug(String);

§#[openapi_header(...)] options:

  • name = "..." a required parameter with the header name
  • description = "..." an optional description for the header
  • required = false an optional parameter, default value is false
  • deprecated = false an optional parameter, default value is false

Because this macro requires JsonSchema, all attributes supported by JsonSchema are forwarded to this implementation.