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

Feat std::collections::LinkedList as a known field type for schema #748

Merged
merged 4 commits into from
Aug 31, 2023
Merged

Feat std::collections::LinkedList as a known field type for schema #748

merged 4 commits into from
Aug 31, 2023

Conversation

evgenymng
Copy link
Contributor

One might find std::collections::LinkedList more preferable than Vec, when defining the return type of an API responder. Hence, it would be great to be able to use LinkedList in schema declaration.

This PR registeres LinkedList as another GenericType and makes aforesaid possible.

I am open to any comments and suggestions.

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.

Awesome, just add one test case to schema_derive_test.rs file that tests this LinkedList. There are plenty of test's using Vec so they can work as an example.

@evgenymng
Copy link
Contributor Author

@juhaku, here it is. Take a look.

Also, a bit off-topic, while I was running cargo test utoipa-gen, it complained about enum PathItemType not having #[derive(Debug)] (utoipa/src/openapi/path.rs line 699). Further investigation showed that PathItemType derives Debug if, and only if, feature debug is enabled.

The solution might be to always derive Debug for this enum , or to mark the test case that causes the issue with #[cfg(feature = "debug")]. The latter is not as groundbreaking.

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
Copy link
Owner

juhaku commented Aug 31, 2023

Also, a bit off-topic, while I was running cargo test utoipa-gen, it complained about enum PathItemType not having #[derive(Debug)] (utoipa/src/openapi/path.rs line 699). Further investigation showed that PathItemType derives Debug if, and only if, feature debug is enabled.

The solution might be to always derive Debug for this enum , or to mark the test case that causes the issue with #[cfg(feature = "debug")]. The latter is not as groundbreaking

Yeah, there is the ./scripts/test.sh that is better for running the tests with necessary feature flags. Just bluntly running cargo test -p utoia-gen will not run all the tests. And using --all-features will result errors, because of conflicting implementation for axum, rocket and actix_web. You could run tests individually with custom set of features enabled for your ide as well which is something I usually do. Also just adding necessary features to the cargo command is okay e.g. cargo test --features debug,...x,....y -p utoipa-gen.

},
"values": {
"items": {
"type": "string"
Copy link
Owner

Choose a reason for hiding this comment

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

should this type be: number?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes it should 😄 Check the test failure report, also there are other expectation errors as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. My apologies. Also, I've added the "format": "double" as it's double-precision floating point value.

I've run the tests using ./scripts/test.sh utoipa-gen and it seems like everything is fine.

Copy link
Owner

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 1443ec4 into juhaku:master Aug 31, 2023
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