Skip to content

Commit

Permalink
Optional feature to generate openAPI schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ypo committed Oct 30, 2024
1 parent 1bf31cb commit f4ee8cb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ raptor-code = "1.0.6"
opentelemetry = { version = "0.25", optional = true }
opentelemetry-semantic-conventions = { version = "0.25" , optional = true }
rand = "0.8"
utoipa = { version = "5", optional = true }

[dev-dependencies]
env_logger = "0.11"
Expand All @@ -44,3 +45,4 @@ tempfile = "3.10.1"
[features]
python = ["pyo3", "pyo3-log"]
optel = ["opentelemetry", "opentelemetry-semantic-conventions"]
openapi = ["utoipa"]
1 change: 1 addition & 0 deletions src/common/fdtinstance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ where
}

#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct FdtInstance {
#[serde(rename = "@xmlns", serialize_with = "xmlns")]
pub xmlns: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions src/common/lct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::tools::error::{FluteError, Result};
/// Content Encoding, compressed
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Debug, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum Cenc {
/// Do not encode content before transmission
Null = 0,
Expand Down
6 changes: 6 additions & 0 deletions src/common/oti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::Serialize;
///
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum FECEncodingID {
/// No FEC
NoCode = 0,
Expand Down Expand Up @@ -45,6 +46,7 @@ impl TryFrom<u8> for FECEncodingID {
///
/// Reed Solomon GS2M Scheme Specific parameters
#[derive(Clone, Debug, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct ReedSolomonGF2MSchemeSpecific {
/// Length of the finite field elements, in bits
pub m: u8,
Expand All @@ -57,6 +59,7 @@ pub struct ReedSolomonGF2MSchemeSpecific {
/// RaptorQ Scheme Specific parameters
/// <https://www.rfc-editor.org/rfc/rfc6330.html#section-3.3.3>
#[derive(Clone, Debug, Default, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct RaptorQSchemeSpecific {
/// The number of source blocks (Z): 8-bit unsigned integer.
pub source_blocks_length: u8,
Expand All @@ -75,6 +78,7 @@ pub struct RaptorQSchemeSpecific {
///| Z | N | Al |
///+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(Clone, Debug, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct RaptorSchemeSpecific {
/// The number of source blocks (Z): 16-bit unsigned integer.
pub source_blocks_length: u16,
Expand Down Expand Up @@ -162,6 +166,7 @@ impl RaptorSchemeSpecific {
/// Scheme Specific information
///
#[derive(Clone, Debug, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum SchemeSpecific {
/// if `fec_encoding_id` is `FECEncodingID::ReedSolomonGF2M`
ReedSolomon(ReedSolomonGF2MSchemeSpecific),
Expand All @@ -175,6 +180,7 @@ pub enum SchemeSpecific {
/// FEC Object Transmission Information
/// Contains the parameters using the build the blocks and FEC for the objects transmission
#[derive(Clone, Debug, Serialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct Oti {
/// Select the FEC for the object transmission
pub fec_encoding_id: FECEncodingID,
Expand Down
1 change: 1 addition & 0 deletions src/common/udpendpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};

/// UDP Endpoint
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone, Eq, Hash)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct UDPEndpoint {
/// Network source adress
pub source_address: Option<String>,
Expand Down

0 comments on commit f4ee8cb

Please sign in to comment.