|
@@ -7,6 +7,7 @@ use std::{
|
|
|
use derive_more::derive::From;
|
|
use derive_more::derive::From;
|
|
|
use itertools::Itertools as _;
|
|
use itertools::Itertools as _;
|
|
|
use serde::{de::Error, Deserialize, Serialize};
|
|
use serde::{de::Error, Deserialize, Serialize};
|
|
|
|
|
+use utoipa::ToSchema;
|
|
|
|
|
|
|
|
use crate::{
|
|
use crate::{
|
|
|
payload::AggregatedPriceFeedData,
|
|
payload::AggregatedPriceFeedData,
|
|
@@ -14,11 +15,13 @@ use crate::{
|
|
|
ChannelId, Price, PriceFeedId, PriceFeedProperty, Rate,
|
|
ChannelId, Price, PriceFeedId, PriceFeedProperty, Rate,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct LatestPriceRequestRepr {
|
|
pub struct LatestPriceRequestRepr {
|
|
|
// Either price feed ids or symbols must be specified.
|
|
// Either price feed ids or symbols must be specified.
|
|
|
|
|
+ #[schema(example = json!([1]))]
|
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
|
|
|
+ #[schema(example = schema_default_symbols)]
|
|
|
pub symbols: Option<Vec<String>>,
|
|
pub symbols: Option<Vec<String>>,
|
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
|
// "chains" was renamed to "formats". "chains" is still supported for compatibility.
|
|
// "chains" was renamed to "formats". "chains" is still supported for compatibility.
|
|
@@ -33,7 +36,7 @@ pub struct LatestPriceRequestRepr {
|
|
|
pub channel: Channel,
|
|
pub channel: Channel,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct LatestPriceRequest(LatestPriceRequestRepr);
|
|
pub struct LatestPriceRequest(LatestPriceRequestRepr);
|
|
|
|
|
|
|
@@ -79,12 +82,13 @@ impl DerefMut for LatestPriceRequest {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct PriceRequestRepr {
|
|
pub struct PriceRequestRepr {
|
|
|
pub timestamp: TimestampUs,
|
|
pub timestamp: TimestampUs,
|
|
|
// Either price feed ids or symbols must be specified.
|
|
// Either price feed ids or symbols must be specified.
|
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
|
|
|
+ #[schema(default)]
|
|
|
pub symbols: Option<Vec<String>>,
|
|
pub symbols: Option<Vec<String>>,
|
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
|
pub formats: Vec<Format>,
|
|
pub formats: Vec<Format>,
|
|
@@ -97,7 +101,7 @@ pub struct PriceRequestRepr {
|
|
|
pub channel: Channel,
|
|
pub channel: Channel,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct PriceRequest(PriceRequestRepr);
|
|
pub struct PriceRequest(PriceRequestRepr);
|
|
|
|
|
|
|
@@ -143,7 +147,7 @@ impl DerefMut for PriceRequest {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct ReducePriceRequest {
|
|
pub struct ReducePriceRequest {
|
|
|
pub payload: JsonUpdate,
|
|
pub payload: JsonUpdate,
|
|
@@ -158,7 +162,14 @@ pub fn default_parsed() -> bool {
|
|
|
true
|
|
true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
|
|
|
|
|
|
+pub fn schema_default_symbols() -> Option<Vec<String>> {
|
|
|
|
|
+ None
|
|
|
|
|
+}
|
|
|
|
|
+pub fn schema_default_price_feed_ids() -> Option<Vec<PriceFeedId>> {
|
|
|
|
|
+ Some(vec![PriceFeedId(1)])
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub enum DeliveryFormat {
|
|
pub enum DeliveryFormat {
|
|
|
/// Deliver stream updates as JSON text messages.
|
|
/// Deliver stream updates as JSON text messages.
|
|
@@ -168,7 +179,7 @@ pub enum DeliveryFormat {
|
|
|
Binary,
|
|
Binary,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub enum Format {
|
|
pub enum Format {
|
|
|
Evm,
|
|
Evm,
|
|
@@ -177,7 +188,7 @@ pub enum Format {
|
|
|
LeUnsigned,
|
|
LeUnsigned,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub enum JsonBinaryEncoding {
|
|
pub enum JsonBinaryEncoding {
|
|
|
#[default]
|
|
#[default]
|
|
@@ -185,9 +196,11 @@ pub enum JsonBinaryEncoding {
|
|
|
Hex,
|
|
Hex,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, From)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, From, ToSchema)]
|
|
|
|
|
+#[schema(example = "fixed_rate@200ms")]
|
|
|
pub enum Channel {
|
|
pub enum Channel {
|
|
|
FixedRate(FixedRate),
|
|
FixedRate(FixedRate),
|
|
|
|
|
+ #[schema(rename = "real_time")]
|
|
|
RealTime,
|
|
RealTime,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -275,11 +288,12 @@ impl<'de> Deserialize<'de> for Channel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscriptionParamsRepr {
|
|
pub struct SubscriptionParamsRepr {
|
|
|
// Either price feed ids or symbols must be specified.
|
|
// Either price feed ids or symbols must be specified.
|
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
pub price_feed_ids: Option<Vec<PriceFeedId>>,
|
|
|
|
|
+ #[schema(default)]
|
|
|
pub symbols: Option<Vec<String>>,
|
|
pub symbols: Option<Vec<String>>,
|
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
pub properties: Vec<PriceFeedProperty>,
|
|
|
// "chains" was renamed to "formats". "chains" is still supported for compatibility.
|
|
// "chains" was renamed to "formats". "chains" is still supported for compatibility.
|
|
@@ -299,7 +313,7 @@ pub struct SubscriptionParamsRepr {
|
|
|
pub ignore_invalid_feeds: bool,
|
|
pub ignore_invalid_feeds: bool,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscriptionParams(SubscriptionParamsRepr);
|
|
pub struct SubscriptionParams(SubscriptionParamsRepr);
|
|
|
|
|
|
|
@@ -345,14 +359,14 @@ impl DerefMut for SubscriptionParams {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct JsonBinaryData {
|
|
pub struct JsonBinaryData {
|
|
|
pub encoding: JsonBinaryEncoding,
|
|
pub encoding: JsonBinaryEncoding,
|
|
|
pub data: String,
|
|
pub data: String,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct JsonUpdate {
|
|
pub struct JsonUpdate {
|
|
|
/// Present unless `parsed = false` is specified in subscription params.
|
|
/// Present unless `parsed = false` is specified in subscription params.
|
|
@@ -372,7 +386,7 @@ pub struct JsonUpdate {
|
|
|
pub le_unsigned: Option<JsonBinaryData>,
|
|
pub le_unsigned: Option<JsonBinaryData>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct ParsedPayload {
|
|
pub struct ParsedPayload {
|
|
|
#[serde(with = "crate::serde_str::timestamp")]
|
|
#[serde(with = "crate::serde_str::timestamp")]
|
|
@@ -380,7 +394,7 @@ pub struct ParsedPayload {
|
|
|
pub price_feeds: Vec<ParsedFeedPayload>,
|
|
pub price_feeds: Vec<ParsedFeedPayload>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct ParsedFeedPayload {
|
|
pub struct ParsedFeedPayload {
|
|
|
pub price_feed_id: PriceFeedId,
|
|
pub price_feed_id: PriceFeedId,
|
|
@@ -491,7 +505,7 @@ impl ParsedFeedPayload {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A request sent from the client to the server.
|
|
/// A request sent from the client to the server.
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(tag = "type")]
|
|
#[serde(tag = "type")]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub enum WsRequest {
|
|
pub enum WsRequest {
|
|
@@ -499,10 +513,12 @@ pub enum WsRequest {
|
|
|
Unsubscribe(UnsubscribeRequest),
|
|
Unsubscribe(UnsubscribeRequest),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(
|
|
|
|
|
+ Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, ToSchema,
|
|
|
|
|
+)]
|
|
|
pub struct SubscriptionId(pub u64);
|
|
pub struct SubscriptionId(pub u64);
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscribeRequest {
|
|
pub struct SubscribeRequest {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
@@ -510,14 +526,14 @@ pub struct SubscribeRequest {
|
|
|
pub params: SubscriptionParams,
|
|
pub params: SubscriptionParams,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct UnsubscribeRequest {
|
|
pub struct UnsubscribeRequest {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A JSON response sent from the server to the client.
|
|
/// A JSON response sent from the server to the client.
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, From)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, From, ToSchema)]
|
|
|
#[serde(tag = "type")]
|
|
#[serde(tag = "type")]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub enum WsResponse {
|
|
pub enum WsResponse {
|
|
@@ -530,13 +546,13 @@ pub enum WsResponse {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Sent from the server after a successul subscription.
|
|
/// Sent from the server after a successul subscription.
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscribedResponse {
|
|
pub struct SubscribedResponse {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct InvalidFeedSubscriptionDetails {
|
|
pub struct InvalidFeedSubscriptionDetails {
|
|
|
pub unknown_ids: Vec<PriceFeedId>,
|
|
pub unknown_ids: Vec<PriceFeedId>,
|
|
@@ -545,7 +561,7 @@ pub struct InvalidFeedSubscriptionDetails {
|
|
|
pub unstable: Vec<PriceFeedId>,
|
|
pub unstable: Vec<PriceFeedId>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscribedWithInvalidFeedIdsIgnoredResponse {
|
|
pub struct SubscribedWithInvalidFeedIdsIgnoredResponse {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
@@ -553,7 +569,7 @@ pub struct SubscribedWithInvalidFeedIdsIgnoredResponse {
|
|
|
pub ignored_invalid_feed_ids: InvalidFeedSubscriptionDetails,
|
|
pub ignored_invalid_feed_ids: InvalidFeedSubscriptionDetails,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct UnsubscribedResponse {
|
|
pub struct UnsubscribedResponse {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
@@ -561,7 +577,7 @@ pub struct UnsubscribedResponse {
|
|
|
|
|
|
|
|
/// Sent from the server if the requested subscription or unsubscription request
|
|
/// Sent from the server if the requested subscription or unsubscription request
|
|
|
/// could not be fulfilled.
|
|
/// could not be fulfilled.
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct SubscriptionErrorResponse {
|
|
pub struct SubscriptionErrorResponse {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|
|
@@ -570,7 +586,7 @@ pub struct SubscriptionErrorResponse {
|
|
|
|
|
|
|
|
/// Sent from the server if an internal error occured while serving data for an existing subscription,
|
|
/// Sent from the server if an internal error occured while serving data for an existing subscription,
|
|
|
/// or a client request sent a bad request.
|
|
/// or a client request sent a bad request.
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct ErrorResponse {
|
|
pub struct ErrorResponse {
|
|
|
pub error: String,
|
|
pub error: String,
|
|
@@ -578,7 +594,7 @@ pub struct ErrorResponse {
|
|
|
|
|
|
|
|
/// Sent from the server when new data is available for an existing subscription
|
|
/// Sent from the server when new data is available for an existing subscription
|
|
|
/// (only if `delivery_format == Json`).
|
|
/// (only if `delivery_format == Json`).
|
|
|
-#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
|
|
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
|
|
|
#[serde(rename_all = "camelCase")]
|
|
#[serde(rename_all = "camelCase")]
|
|
|
pub struct StreamUpdatedResponse {
|
|
pub struct StreamUpdatedResponse {
|
|
|
pub subscription_id: SubscriptionId,
|
|
pub subscription_id: SubscriptionId,
|