Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrap doc comments to always have a succinct first paragraph #1418

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bridge/svix-bridge-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ pub struct CreateMessageRequest {
}

/// Receivers convert HTTP bodies into messages forwarded to (currently only) message queues, etc.
///
/// The `payload` field represents the message body given to the producer, and other fields may be
/// added in the future allowing transformations to dynamically customize the producer behavior.
#[derive(Clone, Deserialize, Serialize)]
Expand Down
9 changes: 6 additions & 3 deletions server/svix-server/src/core/idempotency.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// SPDX-FileCopyrightText: © 2022 Svix Authors
// SPDX-License-Identifier: MIT

//! Defines idempotency middleware for the Axum server which first looks up the given key for an
//! existing response before routing to the given endpoint's function, and caches any such results
//! such that subsequent requests to that endpoint with the same key will return the same response.
//! Idempotency middleware for the Axum server.
//!
//! The middleware first looks up the given key for an existing response before
//! routing to the given endpoint's function, and caches any such results
//! such that subsequent requests to that endpoint with the same key will return
//! the same response.
//!
//! Responses are cached for twelve hours by default.

Expand Down
8 changes: 5 additions & 3 deletions server/svix-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,11 @@ impl From<crate::core::webhook_http_client::Error> for Error {
}
}

/// Utility function for Converting a [`DbErr`] into an [`HttpError`] (wrapped by [`Error`]) on the
/// error "duplicate key value violates unique constraint". This is to be used in `map_err` calls
/// on creation/update of records
/// Utility function for Converting a [`DbErr`] into an [`Error`].
///
/// The error "duplicate key value violates unique constraint" is converted to
/// an HTTP "conflict" error. This is to be used in `map_err` calls on
/// creation/update of records.
pub fn http_error_on_conflict(db_err: DbErr) -> Error {
if is_conflict_err(&db_err) {
HttpError::conflict(None, None).into()
Expand Down
11 changes: 7 additions & 4 deletions server/svix-server/src/v1/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ pub struct EventTypeNamePath {
}

/// JsonStatus is a wrapper over `axum::extract::Json` as a handler output.
///
/// Setting the `STATUS` const parameter automatically sets the response
/// status code, as well as inserting it into the aide documentation.
pub struct JsonStatus<const STATUS: u16, T: JsonSchema + Serialize>(pub T);
Expand Down Expand Up @@ -793,10 +794,12 @@ impl<const STATUS: u16, T: JsonSchema + Serialize> OperationOutput for JsonStatu
}

/// JsonStatusUpsert is a wrapper over `axum::extract::Json` as a handler
/// output. It is a special casing of `JsonStatus` for situations where a
/// resource is either being updated or created within the same operation. In
/// case of `Updated` HTTP 200 OK is returned, in case of `Created` HTTP 201
/// CREATED is returned.
/// output.
///
/// It is a special casing of `JsonStatus` for situations where a resource is
/// either being updated or created within the same operation. In case of
/// `Updated` HTTP 200 OK is returned, in case of `Created` HTTP 201 CREATED
/// is returned.
pub enum JsonStatusUpsert<T: JsonSchema + Serialize> {
Updated(T),
Created(T),
Expand Down
30 changes: 17 additions & 13 deletions server/svix-server/src/v1/utils/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use validator::Validate;

/// This is an enum that will wrap every nullable field for a PATCH request. Nonnullable fields can
/// be represented via an [`UnrequiredField`]. This differs from an [`Option`] in that it
/// distinguishes null values and absent values such that an optional value in a model may be made
/// None via PATCHing while allowing omitted fields to be skipped when updating.
/// This is an enum that will wrap every nullable field for a PATCH request.
///
/// NOTE: You must tag these fields with `#[serde(default)]` in order for the serialization to work
/// correctly.
/// Nonnullable fields can be represented via an [`UnrequiredField`]. This
/// differs from an [`Option`] in that it distinguishes null values and absent
/// values such that an optional value in a model may be made `None` via
/// PATCHing while allowing omitted fields to be skipped when updating.
///
/// NOTE: You must tag these fields with `#[serde(default)]` in order for the
/// serialization to work correctly.
#[derive(Debug)]
pub enum UnrequiredNullableField<T> {
Absent,
None,
Some(T),
}

/// This enum is a non-nullable equivalent to [`UnrequiredNullableField`]. This is effectively an
/// [`Option`] with the additional context that any field which uses this type is a member of a
/// PATCH request model and that the field may be absent, meaning it is not to be updated. In
/// comparison, [`Option`]s are used in other [`ModelIn`]s to define a field, that when absent,
/// is `null`.
/// This enum is a non-nullable equivalent to [`UnrequiredNullableField`].
///
/// This is effectively an [`Option`] with the additional context that any field
/// which uses this type is a member of a PATCH request model and that the field
/// may be absent, meaning it is not to be updated. In comparison, [`Option`]s
/// are used in other [`ModelIn`]s to define a field, that when absent, is
/// `null`.
///
/// NOTE: You must tag these fields with `#[serde(default)]` in order for the serialization to work
/// correctly.
/// NOTE: You must tag these fields with `#[serde(default)]` in order for the
/// serialization to work correctly.
#[derive(Debug)]
pub enum UnrequiredField<T> {
Absent,
Expand Down
9 changes: 5 additions & 4 deletions server/svix-server_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ pub fn derive_model_out(input: proc_macro::TokenStream) -> proc_macro::TokenStre
}

#[proc_macro_attribute]
/// Attribute macro for axum/aide handler functions that creates a new function
/// with the same name as the handler, suffixed with `_operation`, that acts as
/// an operation transformation function, automatically setting the operation
/// ID, summary and description.
/// Generate an aide operation transform for an axum handler function.
///
/// The generated function has the same name as the handler, suffixed with
/// `_operation`. It automatically sets the operation ID, summary and
/// description.
///
/// # Example
/// ```ignore
Expand Down