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

Support ULID #733

Merged
merged 3 commits into from
Aug 13, 2023
Merged

Support ULID #733

merged 3 commits into from
Aug 13, 2023

Conversation

pbzweihander
Copy link
Contributor

This PR adds support for ulid.

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems otherwise good, just a test missing from schema_derive_test.rs for the ulid case.

Also perhaps the known format thingy could be bit refactored.

#[cfg(not(any(feature = "uuid", feature = "ulid")))]
{
  true
}
#[cfg(all(feature = "uuid", not(feature = "ulid")))]
{
  format != "Ulid"
}
#[cfg(all(feature = "ulid", not(feature = "uuid")))]
{
  format != "Uuid"
}

utoipa-gen/src/schema_type.rs Outdated Show resolved Hide resolved
@pbzweihander
Copy link
Contributor Author

Can you help with the test? I'm not sure how to write one

@juhaku
Copy link
Owner

juhaku commented Aug 13, 2023

Can you help with the test? I'm not sure how to write one

fn derive_struct_with_arc() {
use std::sync::Arc;
let greeting = api_doc! {
struct Greeting {
greeting: Arc<String>
}
};
assert_json_eq!(
greeting,
json!({
"properties": {
"greeting": {
"type": "string"
},
},
"required": [
"greeting"
],
"type": "object"
})
)
}

Just like in above one but it it should test a type that has the Ulid type.

#[test]
#[cfg(feature = "ulid")]
fn test {
    #[derive(ToSchema)]
    struct Foo {
        value: Ulid,
    }
    
    // ... and so on the assertion
}

@pbzweihander
Copy link
Contributor Author

I added test. Thanks!

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🏆

@juhaku juhaku merged commit 0c49940 into juhaku:master Aug 13, 2023
5 checks passed
@pbzweihander pbzweihander deleted the ulid branch August 13, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants