diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d3c34d3ad..9156b0605 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,7 +22,7 @@ jobs: matrix: rust: - name: MSRV - toolchain: "1.60" + toolchain: "1.70" nightly: false - name: Stable toolchain: stable @@ -57,7 +57,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: "1.68" + toolchain: "1.78" id: rust-toolchain - uses: actions/cache@v4 with: @@ -74,7 +74,7 @@ jobs: matrix: rust: - name: MSRV - toolchain: "1.60" + toolchain: "1.70" nightly: false - name: Nightly toolchain: nightly @@ -144,7 +144,7 @@ jobs: --workspace \ --all-features \ --exclude-files 'derive/*' \ - --exclude-files 'serde/*' \ + --exclude-files 'serde/*' \ --exclude-files 'target/*' \ --ignore-panics --ignore-tests \ --out html --out json \ diff --git a/Cargo.toml b/Cargo.toml index 87ad4d277..f71655529 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "openapi_type" version = "0.4.3" authors = ["Dominic Meiser "] edition = "2021" -rust-version = "1.60" +rust-version = "1.70" description = "OpenAPI type information for Rust structs and enums" keywords = ["openapi", "type"] license = "Apache-2.0" @@ -41,4 +41,4 @@ uuid1 = { package = "uuid", version = "1", optional = true } paste = "1.0" pretty_assertions = "1.0" serde = { version = "1.0.158", features = ["derive"] } -trybuild = "=1.0.89" +trybuild = "=1.0.95" diff --git a/README.j2 b/README.j2 index 6336eff41..ae47cd534 100644 --- a/README.j2 +++ b/README.j2 @@ -9,8 +9,8 @@ rustdoc - - Rust 1.60+ + + Rust 1.70+ License Apache-2.0 diff --git a/README.md b/README.md index e2cac84de..407411b75 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ rustdoc - - Rust 1.60+ + + Rust 1.70+ License Apache-2.0 @@ -29,15 +29,20 @@ This repository contains the following crates: # openapi_type -This crate gives static type information for primitives and commonly used types from the standard library and other commonly used libraries `chrono`, `indexmap`, `linked-hash-map`, `time` and `uuid` when the according feature is enabled. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime. - -The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, [`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static type information in a way that is convenient to use for a generated OpenAPI specification, but can also be utilized in other use cases as well. +This crate gives static type information for primitives and commonly used types from the standard +library and other commonly used libraries `chrono`, `indexmap`, `linked-hash-map`, `time` and +`uuid` when the according feature is enabled. Also, it provides a derive macro for structs and +enums to gain access to their static type information at runtime. +The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, +[`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static +type information in a way that is convenient to use for a generated OpenAPI specification, but +can also be utilized in other use cases as well. ## Custom Types -To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro: - +To gain access to the static type information of your custom types at runtime, the easiest way +is to use the derive macro: ```rust #[derive(OpenapiType)] @@ -47,12 +52,10 @@ struct FooBar { } ``` - ## OpenAPI specification Using above type, running `FooBar::schema().into_schema()` yields - ```yaml type: object title: FooBar @@ -68,8 +71,11 @@ required: - bar ``` -Note, however, that this is not sufficient for more complex types. If one of your structs fields is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain a reference to that schema. Therefore, always remember to put the [`dependencies`][__link3] into the specification alongside the type you are interested in. - +Note, however, that this is not sufficient for more complex types. If one of your structs fields +is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain +a reference to that schema. Therefore, always remember to put the +[`dependencies`][__link3] into the specification alongside the type you are +interested in. ## Versioning @@ -96,7 +102,7 @@ limitations under the License. ``` [contributors]: https://github.com/msrd0/openapi_type/graphs/contributors - [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG6PuuoPOlUFDG0-OepI01YiZG6RFyDnCkT_6G-ccbKs9_t1xYXKEGx-WnjBiXfMmG4V3M75ny0WUG3hGD9I-WPRHG94Lm2E6FONkYWSBgmxvcGVuYXBpX3R5cGVlMC40LjM + [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGx04nilVverNG3ce8eYhySS2G0k6-WaJRzmPGyiP7D_wJH3uYXKEGx-WnjBiXfMmG4V3M75ny0WUG3hGD9I-WPRHG94Lm2E6FONkYWSBgmxvcGVuYXBpX3R5cGVlMC40LjM [__link0]: https://docs.rs/openapi_type/0.4.3/openapi_type/trait.OpenapiType.html [__link1]: https://docs.rs/openapi_type/0.4.3/openapi_type/?search=OpenapiType::schema [__link2]: https://docs.rs/openapi_type/0.4.3/openapi_type/?search=OpenapiSchema diff --git a/crates-io.j2 b/crates-io.j2 index dea61abc8..9e0fd7871 100644 --- a/crates-io.j2 +++ b/crates-io.j2 @@ -1,4 +1,4 @@ -# openapi_type [![Rust 1.60+](https://img.shields.io/badge/rustc-1.60+-orange.svg)](https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type) +# openapi_type [![Rust 1.70+](https://img.shields.io/badge/rustc-1.70+-orange.svg)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type) {{ readme }} diff --git a/crates-io.md b/crates-io.md index 380494da6..cf87004c6 100644 --- a/crates-io.md +++ b/crates-io.md @@ -1,14 +1,19 @@ -# openapi_type [![Rust 1.60+](https://img.shields.io/badge/rustc-1.60+-orange.svg)](https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type) +# openapi_type [![Rust 1.70+](https://img.shields.io/badge/rustc-1.70+-orange.svg)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html) [![License Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub](https://img.shields.io/badge/Code-On%20Github-blue?logo=GitHub)](https://github.com/msrd0/openapi_type) -This crate gives static type information for primitives and commonly used types from the standard library and other commonly used libraries `chrono`, `indexmap`, `linked-hash-map`, `time` and `uuid` when the according feature is enabled. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime. - -The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, [`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static type information in a way that is convenient to use for a generated OpenAPI specification, but can also be utilized in other use cases as well. +This crate gives static type information for primitives and commonly used types from the standard +library and other commonly used libraries `chrono`, `indexmap`, `linked-hash-map`, `time` and +`uuid` when the according feature is enabled. Also, it provides a derive macro for structs and +enums to gain access to their static type information at runtime. +The core of this crate is the [`OpenapiType`][__link0] trait. It has one static function, +[`schema`][__link1], which returns an [`OpenapiSchema`][__link2]. This assembles the static +type information in a way that is convenient to use for a generated OpenAPI specification, but +can also be utilized in other use cases as well. ## Custom Types -To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro: - +To gain access to the static type information of your custom types at runtime, the easiest way +is to use the derive macro: ```rust #[derive(OpenapiType)] @@ -18,12 +23,10 @@ struct FooBar { } ``` - ## OpenAPI specification Using above type, running `FooBar::schema().into_schema()` yields - ```yaml type: object title: FooBar @@ -39,8 +42,11 @@ required: - bar ``` -Note, however, that this is not sufficient for more complex types. If one of your structs fields is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain a reference to that schema. Therefore, always remember to put the [`dependencies`][__link3] into the specification alongside the type you are interested in. - +Note, however, that this is not sufficient for more complex types. If one of your structs fields +is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain +a reference to that schema. Therefore, always remember to put the +[`dependencies`][__link3] into the specification alongside the type you are +interested in. ## Versioning @@ -67,7 +73,7 @@ limitations under the License. ``` [contributors]: https://github.com/msrd0/openapi_type/graphs/contributors - [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG00blYWrE2YXG_rPohqkhF51G648HnGd6dB7G72lCqGVpeT8YXKEGx-WnjBiXfMmG4V3M75ny0WUG3hGD9I-WPRHG94Lm2E6FONkYWSBgmxvcGVuYXBpX3R5cGVlMC40LjM + [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG08sBLszLNKMG1ienvOWfn_8G_o9NT-2LMz5G_3E1vsqLiEoYXKEGx-WnjBiXfMmG4V3M75ny0WUG3hGD9I-WPRHG94Lm2E6FONkYWSBgmxvcGVuYXBpX3R5cGVlMC40LjM [__link0]: https://docs.rs/openapi_type/0.4.3/openapi_type/trait.OpenapiType.html [__link1]: https://docs.rs/openapi_type/0.4.3/openapi_type/?search=OpenapiType::schema [__link2]: https://docs.rs/openapi_type/0.4.3/openapi_type/?search=OpenapiSchema diff --git a/src/lib.rs b/src/lib.rs index b4f0f1ef4..18f3419d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ +#![allow(clippy::tabs_in_doc_comments)] #![warn(missing_debug_implementations, rust_2018_idioms)] #![deny(rustdoc::broken_intra_doc_links)] #![forbid(unsafe_code)] -#![cfg_attr(feature = "cargo-clippy", allow(clippy::tabs_in_doc_comments))] #![doc = r##" This crate gives static type information for primitives and commonly used types from the standard library and other commonly used libraries `chrono`, `indexmap`, `linked-hash-map`, `time` and diff --git a/tests/fail/not_openapitype.stderr b/tests/fail/not_openapitype.stderr index 5e5592fa1..a9f0bed9a 100644 --- a/tests/fail/not_openapitype.stderr +++ b/tests/fail/not_openapitype.stderr @@ -5,12 +5,12 @@ error[E0277]: the trait bound `Bar: OpenapiType` is not satisfied | ^^^ the trait `OpenapiType` is not implemented for `Bar` | = help: the following other types implement trait `OpenapiType`: - &'a T - () - BTreeMap - BTreeSet - CStr - CString - Foo - HashMap + bool + char + isize + i8 + i16 + i32 + i64 + i128 and $N others diff --git a/tests/fail/not_openapitype_generics.stderr b/tests/fail/not_openapitype_generics.stderr index 079deae6e..4439553ca 100644 --- a/tests/fail/not_openapitype_generics.stderr +++ b/tests/fail/not_openapitype_generics.stderr @@ -2,10 +2,7 @@ error[E0599]: the function or associated item `schema` exists for struct `Foo tests/fail/not_openapitype_generics.rs:11:14 | 4 | struct Foo { - | ------------- - | | - | function or associated item `schema` not found for this struct - | doesn't satisfy `Foo: OpenapiType` + | ------------- function or associated item `schema` not found for this struct because it doesn't satisfy `Foo: OpenapiType` ... 8 | struct Bar; | ---------- doesn't satisfy `Bar: OpenapiType`