You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,18 +32,15 @@ This repository contains the following crates:
32
32
33
33
# openapi_type
34
34
35
-
This crate gives static type information for primitives and commonly used types from the standard
36
-
library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a
37
-
derive macro for structs and enums to gain access to their static type information at runtime.
35
+
This crate gives static type information for primitives and commonly used types from the standard library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime.
36
+
37
+
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.
38
38
39
-
The core of this crate is the [`OpenapiType`] trait. It has one static function,
40
-
[`schema`](OpenapiType::schema), which returns an [`OpenapiSchema`]. This assembles the static
41
-
type information in a way that is convenient to use for a generated OpenAPI specification, but
42
-
can also be utilized in other use cases as well.
43
39
44
40
## Custom Types
45
-
To gain access to the static type information of your custom types at runtime, the easiest way
46
-
is to use the derive macro:
41
+
42
+
To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro:
43
+
47
44
48
45
```rust
49
46
#[derive(OpenapiType)]
@@ -53,9 +50,12 @@ struct FooBar {
53
50
}
54
51
```
55
52
53
+
56
54
## OpenAPI specification
55
+
57
56
Using above type, running `FooBar::schema().into_schema()` yields
58
57
58
+
59
59
```yaml
60
60
type: object
61
61
title: FooBar
@@ -71,11 +71,9 @@ required:
71
71
- bar
72
72
```
73
73
74
-
Note, however, that this is not sufficient for more complex types. If one of your structs fields
75
-
is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain
76
-
a reference to that schema. Therefore, always remember to put the
77
-
[`dependencies`](OpenapiSchema::dependencies) into the specification alongside the type you are
78
-
interested in.
74
+
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.
75
+
76
+
79
77
80
78
## Versioning
81
79
@@ -84,7 +82,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
84
82
85
83
## License
86
84
87
-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
85
+
Copyright (C) 2021 Dominic Meiser and [contributors].
88
86
89
87
```
90
88
Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,3 +97,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
97
See the License for the specific language governing permissions and
This crate gives static type information for primitives and commonly used types from the standard
4
-
library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a
5
-
derive macro for structs and enums to gain access to their static type information at runtime.
3
+
This crate gives static type information for primitives and commonly used types from the standard library and a few other commonly used libraries like `chrono` and `uuid`. Also, it provides a derive macro for structs and enums to gain access to their static type information at runtime.
4
+
5
+
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.
6
6
7
-
The core of this crate is the [`OpenapiType`] trait. It has one static function,
8
-
[`schema`](OpenapiType::schema), which returns an [`OpenapiSchema`]. This assembles the static
9
-
type information in a way that is convenient to use for a generated OpenAPI specification, but
10
-
can also be utilized in other use cases as well.
11
7
12
8
## Custom Types
13
-
To gain access to the static type information of your custom types at runtime, the easiest way
14
-
is to use the derive macro:
9
+
10
+
To gain access to the static type information of your custom types at runtime, the easiest way is to use the derive macro:
11
+
15
12
16
13
```rust
17
14
#[derive(OpenapiType)]
@@ -21,9 +18,12 @@ struct FooBar {
21
18
}
22
19
```
23
20
21
+
24
22
## OpenAPI specification
23
+
25
24
Using above type, running `FooBar::schema().into_schema()` yields
26
25
26
+
27
27
```yaml
28
28
type: object
29
29
title: FooBar
@@ -39,11 +39,9 @@ required:
39
39
- bar
40
40
```
41
41
42
-
Note, however, that this is not sufficient for more complex types. If one of your structs fields
43
-
is a type that has a name (that is, `Type::schema().name` is not `None`), above schema will contain
44
-
a reference to that schema. Therefore, always remember to put the
45
-
[`dependencies`](OpenapiSchema::dependencies) into the specification alongside the type you are
46
-
interested in.
42
+
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.
43
+
44
+
47
45
48
46
## Versioning
49
47
@@ -52,7 +50,7 @@ the MSRV (minimum supported rust version) is not considered a breaking change.
52
50
53
51
## License
54
52
55
-
Copyright (C) 2021 Dominic Meiser and [contributors](https://github.com/msrd0/openapi_type/graphs/contributors).
53
+
Copyright (C) 2021 Dominic Meiser and [contributors].
56
54
57
55
```
58
56
Licensed under the Apache License, Version 2.0 (the "License");
@@ -67,3 +65,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67
65
See the License for the specific language governing permissions and
0 commit comments