Skip to content

Commit 99298dd

Browse files
authored
Simplify macro code by introducing a visitor trait (#30)
1 parent 31dd985 commit 99298dd

23 files changed

+1491
-645
lines changed

.github/workflows/rust.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
toolchain: [1.56, stable, beta]
13+
toolchain: [1.58, stable, beta]
1414
nightly: [false]
1515
include:
1616
- toolchain: nightly
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/checkout@v2
4444
- uses: dtolnay/rust-toolchain@master
4545
with:
46-
toolchain: "1.57"
46+
toolchain: "1.58"
4747
- name: Get Rust Version
4848
id: rust-version
4949
run: echo "::set-output name=version::$(cargo -V | head -n1 | awk '{print $2}')"
@@ -64,7 +64,7 @@ jobs:
6464
- uses: actions/checkout@v2
6565
- uses: dtolnay/rust-toolchain@master
6666
with:
67-
toolchain: "1.57"
67+
toolchain: "1.58"
6868
components: clippy
6969
- name: Get Rust Version
7070
id: rust-version

Cargo.toml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,32 @@ name = "openapi_type"
88
version = "0.3.1"
99
authors = ["Dominic Meiser <[email protected]>"]
1010
edition = "2021"
11-
rust-version = "1.56"
11+
rust-version = "1.58"
1212
description = "OpenAPI type information for Rust structs and enums"
1313
keywords = ["openapi", "type"]
1414
license = "Apache-2.0"
1515
repository = "https://github.com/msrd0/openapi_type"
1616
readme = "crates-io.md"
1717
include = ["src/**/*", "LICENSE", "crates-io.md"]
1818

19+
[features]
20+
chrono = ["chrono04"]
21+
linked-hash-map = ["linked-hash-map05"]
22+
time = ["time03"]
23+
uuid = ["uuid08"]
24+
1925
[dependencies]
2026
indexmap = "1.7"
2127
openapi_type_derive = { path = "./derive", version = "0.3.0" }
2228
openapiv3 = "1.0"
29+
readonly = "0.2"
2330
serde_json = "1.0"
2431

2532
# optional dependencies / features
26-
chrono = { version = "0.4.19", default-features = false, optional = true }
27-
linked-hash-map = { version = "0.5.4", optional = true }
28-
time = { version = "0.3.4", features = ["serde-human-readable"], optional = true }
29-
uuid = { version = "0.8.2", optional = true }
33+
chrono04 = { package = "chrono", version = "0.4", default-features = false, optional = true }
34+
linked-hash-map05 = { package = "linked-hash-map", version = "0.5", optional = true }
35+
time03 = { package = "time", version = "0.3", features = ["serde-human-readable"], optional = true }
36+
uuid08 = { package = "uuid", version = "0.8", optional = true }
3037

3138
[dev-dependencies]
3239
paste = "1.0"

README.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<a href="https://msrd0.github.io/openapi_type/doc/openapi_type/index.html">
1010
<img alt="rustdoc" src="https://img.shields.io/badge/docs-main-blue.svg"/>
1111
</a>
12-
<a href="https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html">
13-
<img alt="Rust 1.56+" src="https://img.shields.io/badge/rustc-1.56+-orange.svg"/>
12+
<a href="https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html">
13+
<img alt="Rust 1.58+" src="https://img.shields.io/badge/rustc-1.58+-orange.svg"/>
1414
</a>
1515
<a href="https://www.apache.org/licenses/LICENSE-2.0">
1616
<img alt="License Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue.svg"/>

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<a href="https://msrd0.github.io/openapi_type/doc/openapi_type/index.html">
1010
<img alt="rustdoc" src="https://img.shields.io/badge/docs-main-blue.svg"/>
1111
</a>
12-
<a href="https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html">
13-
<img alt="Rust 1.56+" src="https://img.shields.io/badge/rustc-1.56+-orange.svg"/>
12+
<a href="https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html">
13+
<img alt="Rust 1.58+" src="https://img.shields.io/badge/rustc-1.58+-orange.svg"/>
1414
</a>
1515
<a href="https://www.apache.org/licenses/LICENSE-2.0">
1616
<img alt="License Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue.svg"/>
@@ -98,5 +98,5 @@ limitations under the License.
9898
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
9999
[__link0]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiType
100100
[__link1]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiType::schema
101-
[__link2]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiSchema
102-
[__link3]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiSchema::dependencies
101+
[__link2]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::visitor::OpenapiSchema
102+
[__link3]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::visitor::OpenapiSchema::dependencies

crates-io.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# openapi_type [![Rust 1.56+](https://img.shields.io/badge/rustc-1.56+-orange.svg)](https://blog.rust-lang.org/2021/10/21/Rust-1.56.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)
1+
# openapi_type [![Rust 1.58+](https://img.shields.io/badge/rustc-1.58+-orange.svg)](https://blog.rust-lang.org/2022/01/13/Rust-1.58.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)
22

33
{{ readme }}
44

crates-io.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# openapi_type [![Rust 1.56+](https://img.shields.io/badge/rustc-1.56+-orange.svg)](https://blog.rust-lang.org/2021/10/21/Rust-1.56.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)
1+
# openapi_type [![Rust 1.58+](https://img.shields.io/badge/rustc-1.58+-orange.svg)](https://blog.rust-lang.org/2022/01/13/Rust-1.58.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)
22

33
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.
44

@@ -69,5 +69,5 @@ limitations under the License.
6969
[contributors]: https://github.com/msrd0/openapi_type/graphs/contributors
7070
[__link0]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiType
7171
[__link1]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiType::schema
72-
[__link2]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiSchema
73-
[__link3]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::OpenapiSchema::dependencies
72+
[__link2]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::visitor::OpenapiSchema
73+
[__link3]: https://docs.rs/openapi_type/0.3.1/openapi_type/?search=openapi_type::visitor::OpenapiSchema::dependencies

derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "openapi_type_derive"
66
version = "0.3.0"
77
authors = ["Dominic Meiser <[email protected]>"]
88
edition = "2021"
9-
rust-version = "1.56"
9+
rust-version = "1.58"
1010
description = "Implementation detail of the openapi_type crate"
1111
license = "Apache-2.0"
1212
repository = "https://github.com/msrd0/openapi_type"

derive/src/attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn unknown(meta: Meta, error_on_unknown: bool) -> syn::Result<()> {
2727

2828
#[derive(Default)]
2929
pub(super) struct ContainerAttributes {
30+
pub(super) doc: Vec<String>,
3031
pub(super) rename: Option<LitStr>,
3132
pub(super) rename_all: Option<LitStr>,
3233
pub(super) tag: Option<LitStr>,

0 commit comments

Comments
 (0)