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

draft proposal for how we might add the x-rust-type extension #47

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
92 changes: 53 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ schemars = { version = "0.8.17", optional = true }
serde = { version = "1", optional = true }
serde_json = { version = "1.0.115", optional = true }
syn = { version = "2.0.48", optional = true }
typify = { version = "0.0.15", optional = true }
typify = { version = "0.1.0", optional = true }

[features]
internal-schemars08-tests = [
Expand Down
54 changes: 54 additions & 0 deletions crates/integration-tests/outputs/schema-rust-with-extension.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/// Error types.
pub mod error {
/// Error from a TryFrom or FromStr implementation.
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///MyPathStruct
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "MyPathStruct",
/// "type": "object",
/// "required": [
/// "id"
/// ],
/// "properties": {
/// "id": {
/// "$ref": "#/definitions/TypedUuidForMyKind"
/// }
/// }
///}
/// ```
/// </details>
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct MyPathStruct {
pub id: ::newtype_uuid::TypedUuid<::my_crate::MyKind>,
}
impl From<&MyPathStruct> for MyPathStruct {
fn from(value: &MyPathStruct) -> Self {
value.clone()
}
}
50 changes: 38 additions & 12 deletions crates/integration-tests/outputs/schema-rust-with-replace.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
/// Error types.
pub mod error {
/// Error from a TryFrom or FromStr implementation.
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///MyPathStruct
///
/// <details><summary>JSON schema</summary>
///
/// ```json
/**{
"title": "MyPathStruct",
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"$ref": "#/definitions/TypedUuidForMyKind"
}
}
}*/
///{
/// "title": "MyPathStruct",
/// "type": "object",
/// "required": [
/// "id"
/// ],
/// "properties": {
/// "id": {
/// "$ref": "#/definitions/TypedUuidForMyKind"
/// }
/// }
///}
/// ```
/// </details>
#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down
Loading
Loading