diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a897da..955b8c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [ "1.75.0", "stable", "nightly" ] + rust: [ "1.85.0", "stable", "nightly" ] steps: - uses: actions/checkout@v4 - name: install toolchain diff --git a/Cargo.toml b/Cargo.toml index f073cb2..a496107 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] authors = ["ProbablyClem", "RxDiscovery", "DenuxPlays"] version = "0.3.0-alpha.2" -edition = "2021" +edition = "2024" keywords = ["utoipa", "openapi", "swagger", "path", "auto"] description = "Rust Macros to automate the addition of Paths/Schemas to Utoipa crate, simulating Reflection during the compilation phase" categories = [ @@ -17,7 +17,7 @@ license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/ProbablyClem/utoipauto" homepage = "https://github.com/ProbablyClem/utoipauto" -rust-version = "1.75.0" +rust-version = "1.85.0" [workspace.dependencies] # Core dependencies diff --git a/acceptance/Cargo.lock b/acceptance/Cargo.lock index cc0e48e..c014237 100644 --- a/acceptance/Cargo.lock +++ b/acceptance/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "folder-in-src" @@ -27,15 +27,15 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "f2481980430f9f78649238835720ddccc57e52df14ffce1c6f37391d61b563e9" dependencies = [ "equivalent", "hashbrown", @@ -44,30 +44,30 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -84,24 +84,24 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utility" @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "utoipa" -version = "5.0.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2b34fc58a72021914a5745832024b2baa638fe771df5a35f3d1b69266bd92c" +checksum = "2fcc29c80c21c31608227e0912b2d7fddba57ad76b606890627ba8ee7964e993" dependencies = [ "indexmap", "serde", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "5.0.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866f11b33be38a747542f435578a164674b8922d958cc065d7f19319c19d4784" +checksum = "6d79d08d92ab8af4c5e8a6da20c47ae3f61a0f1dabc1997cdf2d082b757ca08b" dependencies = [ "proc-macro2", "quote", diff --git a/acceptance/Cargo.toml b/acceptance/Cargo.toml index 349f6a7..818b87e 100644 --- a/acceptance/Cargo.toml +++ b/acceptance/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] authors = ["ProbablyClem", "DenuxPlays", "joaquin041"] version = "0.1.0" -edition = "2021" +edition = "2024" publish = false description = "A collection of crates to test utoipauto." readme = "README.md" diff --git a/acceptance/generics/src/open_api.expected.json b/acceptance/generics/src/open_api.expected.json index a8addeb..cb4327b 100644 --- a/acceptance/generics/src/open_api.expected.json +++ b/acceptance/generics/src/open_api.expected.json @@ -1,302 +1,303 @@ { - "openapi": "3.1.0", - "info": { - "title": "Generic Test Api", - "description": "A collection of crates to test utoipauto.", - "contact": { - "name": "ProbablyClem" + "openapi": "3.1.0", + "info": { + "title": "Generic Test Api", + "description": "A collection of crates to test utoipauto.", + "contact": { + "name": "ProbablyClem" + }, + "license": { + "name": "MIT OR Apache-2.0", + "identifier": "MIT OR Apache-2.0" + }, + "version": "0.1.0" }, - "license": { - "name": "MIT OR Apache-2.0" - }, - "version": "0.1.0" - }, - "paths": { - "/persons": { - "get": { - "tags": [ - "crate::routes" - ], - "operationId": "get_persons", - "responses": { - "200": { - "description": "A Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Response_Person" + "paths": { + "/persons": { + "get": { + "tags": [ + "crate::routes" + ], + "operationId": "get_persons", + "responses": { + "200": { + "description": "A Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_Person" + } + } + } + } } - } } - } - } - } - }, - "/nested_persons": { - "get": { - "tags": [ - "crate::routes" - ], - "operationId": "get_nested_persons", - "responses": { - "200": { - "description": "A NestedResponse", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NestedResponse_Person" + }, + "/nested_persons": { + "get": { + "tags": [ + "crate::routes" + ], + "operationId": "get_nested_persons", + "responses": { + "200": { + "description": "A NestedResponse", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NestedResponse_Person" + } + } + } + } } - } } - } - } - } - }, - "/borrowed_persons": { - "get": { - "tags": [ - "crate::routes" - ], - "operationId": "get_borrowed_persons", - "responses": { - "200": { - "description": "A BorrowedResponse<'static>", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BorrowedResponse" + }, + "/borrowed_persons": { + "get": { + "tags": [ + "crate::routes" + ], + "operationId": "get_borrowed_persons", + "responses": { + "200": { + "description": "A BorrowedResponse<'static>", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BorrowedResponse" + } + } + } + } } - } } - } - } - } - }, - "/nested_borrowed_persons": { - "get": { - "tags": [ - "crate::routes" - ], - "operationId": "get_nested_borrowed_persons", - "responses": { - "200": { - "description": "A NestedBorrowedResponse<'static, Person>", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NestedBorrowedResponse_Person" + }, + "/nested_borrowed_persons": { + "get": { + "tags": [ + "crate::routes" + ], + "operationId": "get_nested_borrowed_persons", + "responses": { + "200": { + "description": "A NestedBorrowedResponse<'static, Person>", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NestedBorrowedResponse_Person" + } + } + } + } } - } } - } - } - } - }, - "/combined_persons": { - "get": { - "tags": [ - "crate::routes" - ], - "operationId": "get_combined_persons", - "responses": { - "200": { - "description": "A CombinedResponse<'static, Person>", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CombinedResponse_Person" + }, + "/combined_persons": { + "get": { + "tags": [ + "crate::routes" + ], + "operationId": "get_combined_persons", + "responses": { + "200": { + "description": "A CombinedResponse<'static, Person>", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CombinedResponse_Person" + } + } + } + } } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "BorrowedResponse": { - "type": "object", - "required": [ - "data", - "additional" - ], - "properties": { - "additional": { - "type": "object", - "additionalProperties": { - "type": "integer", - "format": "int32" - }, - "propertyNames": { - "type": "string" } - }, - "data": { - "type": "string" - } } - }, - "CombinedResponse_Person": { - "type": "object", - "required": [ - "nested_response", - "borrowed_response" - ], - "properties": { - "borrowed_response": { - "$ref": "#/components/schemas/NestedBorrowedResponse_Person" - }, - "nested_response": { - "$ref": "#/components/schemas/NestedResponse_Person" - } - } - }, - "NestedBorrowedResponse_Person": { - "type": "object", - "required": [ - "status", - "data" - ], - "properties": { - "data": { - "type": "object", - "required": [ - "name", - "age" - ], - "properties": { - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "name": { - "type": "string" - } - } - }, - "status": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } - }, - "NestedResponse_Person": { - "type": "object", - "required": [ - "response" - ], - "properties": { - "response": { - "$ref": "#/components/schemas/Response_Person" - } - } - }, - "Person": { - "type": "object", - "required": [ - "name", - "age" - ], - "properties": { - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "name": { - "type": "string" - } - } - }, - "Response_Person": { - "type": "object", - "required": [ - "status", - "data" - ], - "properties": { - "data": { - "type": "object", - "required": [ - "name", - "age" - ], - "properties": { - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "name": { - "type": "string" - } - } - }, - "status": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } - } }, - "responses": { - "BorrowedResponse": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "data", - "additional" - ], - "properties": { - "additional": { - "type": "object", - "additionalProperties": { - "type": "integer", - "format": "int32" - }, - "propertyNames": { - "type": "string" - } - }, - "data": { - "type": "string" + "components": { + "schemas": { + "BorrowedResponse": { + "type": "object", + "required": [ + "data", + "additional" + ], + "properties": { + "additional": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + }, + "propertyNames": { + "type": "string" + } + }, + "data": { + "type": "string" + } + } + }, + "CombinedResponse_Person": { + "type": "object", + "required": [ + "nested_response", + "borrowed_response" + ], + "properties": { + "borrowed_response": { + "$ref": "#/components/schemas/NestedBorrowedResponse_Person" + }, + "nested_response": { + "$ref": "#/components/schemas/NestedResponse_Person" + } + } + }, + "NestedBorrowedResponse_Person": { + "type": "object", + "required": [ + "status", + "data" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "name", + "age" + ], + "properties": { + "age": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "name": { + "type": "string" + } + } + }, + "status": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + } + }, + "NestedResponse_Person": { + "type": "object", + "required": [ + "response" + ], + "properties": { + "response": { + "$ref": "#/components/schemas/Response_Person" + } + } + }, + "Person": { + "type": "object", + "required": [ + "name", + "age" + ], + "properties": { + "age": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "name": { + "type": "string" + } + } + }, + "Response_Person": { + "type": "object", + "required": [ + "status", + "data" + ], + "properties": { + "data": { + "type": "object", + "required": [ + "name", + "age" + ], + "properties": { + "age": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "name": { + "type": "string" + } + } + }, + "status": { + "type": "integer", + "format": "int32", + "minimum": 0 + } } - } } - } - } - }, - "Person": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "name", - "age" - ], - "properties": { - "age": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "name": { - "type": "string" + }, + "responses": { + "BorrowedResponse": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "data", + "additional" + ], + "properties": { + "additional": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + }, + "propertyNames": { + "type": "string" + } + }, + "data": { + "type": "string" + } + } + } + } + } + }, + "Person": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "name", + "age" + ], + "properties": { + "age": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "name": { + "type": "string" + } + } + } + } } - } } - } } - } } - } -} \ No newline at end of file +} diff --git a/acceptance/responses/src/main.rs b/acceptance/responses/src/main.rs index aeaf940..760d010 100644 --- a/acceptance/responses/src/main.rs +++ b/acceptance/responses/src/main.rs @@ -19,8 +19,8 @@ fn main() { #[cfg(test)] mod tests { use crate::ApiDoc; - use utoipa::OpenApi; use utility::assert_json_eq; + use utoipa::OpenApi; pub(crate) const EXPECTED_OPEN_API: &str = include_str!("open_api.expected.json"); #[test] diff --git a/acceptance/responses/src/open_api.expected.json b/acceptance/responses/src/open_api.expected.json index 6e3d15b..4b92515 100644 --- a/acceptance/responses/src/open_api.expected.json +++ b/acceptance/responses/src/open_api.expected.json @@ -7,7 +7,8 @@ "name": "ProbablyClem" }, "license": { - "name": "MIT OR Apache-2.0" + "name": "MIT OR Apache-2.0", + "identifier": "MIT OR Apache-2.0" }, "version": "0.1.0" }, diff --git a/rustfmt.toml b/rustfmt.toml index a0ac89b..9b591f6 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,6 @@ -edition = "2021" +edition = "2024" max_width = 120 newline_style = "Unix" hard_tabs = false tab_spaces = 4 -#group_imports = "StdExternalCrate" # currently a nightly feature \ No newline at end of file +#group_imports = "StdExternalCrate" # currently a nightly feature diff --git a/utoipauto-core/src/attribute_utils.rs b/utoipauto-core/src/attribute_utils.rs index 8f02c42..18c7a3a 100644 --- a/utoipauto-core/src/attribute_utils.rs +++ b/utoipauto-core/src/attribute_utils.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream; -use syn::{punctuated::Punctuated, Attribute, Meta, Token}; +use syn::{Attribute, Meta, Token, punctuated::Punctuated}; pub fn update_openapi_macro_attributes( macro_attibutes: &mut Vec, diff --git a/utoipauto-core/src/discover.rs b/utoipauto-core/src/discover.rs index d7150a5..4039bc7 100644 --- a/utoipauto-core/src/discover.rs +++ b/utoipauto-core/src/discover.rs @@ -3,9 +3,9 @@ use std::vec; use crate::file_utils::{extract_module_name_from_path, parse_files}; use crate::token_utils::Parameters; use quote::ToTokens; -use syn::token::Comma; use syn::Ident; -use syn::{punctuated::Punctuated, Attribute, GenericParam, Item, ItemFn, ItemImpl, Meta, Token}; +use syn::token::Comma; +use syn::{Attribute, GenericParam, Item, ItemFn, ItemImpl, Meta, Token, punctuated::Punctuated}; /// Discover everything from a file, will explore folder recursively pub fn discover_from_file( diff --git a/utoipauto/tests/default_features/models.rs b/utoipauto/tests/default_features/models.rs index 21ea9ec..68fcb25 100644 --- a/utoipauto/tests/default_features/models.rs +++ b/utoipauto/tests/default_features/models.rs @@ -5,8 +5,8 @@ use utoipa::openapi::schema::SchemaType; use utoipa::openapi::{Response, ResponseBuilder, Type}; // This code is used in the tests use utoipa::{ - openapi::{ObjectBuilder, RefOr, Schema}, PartialSchema, ToResponse, ToSchema, + openapi::{ObjectBuilder, RefOr, Schema}, }; use utoipauto_macro::utoipa_ignore;