improve docs and uuid version handling (#65)

This commit is contained in:
Adam Leventhal 2022-05-20 14:52:37 -07:00 committed by GitHub
parent d3441861bc
commit 3cd1eae3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -44,7 +44,19 @@ Similarly if there is a `format` field set to `uuid`:
```diff
[dependencies]
+uuid = { version = "0.8", features = ["serde", "v4"] }
+uuid = { version = "1.0.0", features = ["serde", "v4"] }
```
The macro has some additional fancy options to control the generated code:
```rust
generate_api!(
spec = "path/to/openapi_document.json", // The OpenAPI document
inner_type = my_client::InnerType, // Client inner type available to pre and post hooks
pre_hook = closure::or::path::to::function, // Hook invoked before issuing the HTTP request
post_hook = closure::or::path::to::function, // Hook invoked prior to receiving the HTTP response
derives = [ schemars::JsonSchema ], // Additional derive macros applied to generated types
);
```
Note that the macro will be re-evaluated when the OpenAPI json document
@ -135,7 +147,7 @@ percent-encoding = "2.1"
reqwest = { version = "0.11", features = ["json", "stream"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "0.8", features = ["serde", "v4"] }
uuid = { version = ">=0.8.0, <2.0.0", features = ["serde", "v4"] }
```
Note that there is a dependency on `percent-encoding` which macro- and

View File

@ -210,7 +210,7 @@ impl Generator {
];
if self.type_space.uses_uuid() {
deps.push(
"uuid = { version = \"0.8\", features = [\"serde\", \"v4\"] }",
"uuid = { version = \">=0.8.0, <2.0.0\", features = [\"serde\", \"v4\"] }",
)
}
if self.type_space.uses_chrono() {

View File

@ -21,7 +21,7 @@ use syn::LitStr;
/// The more complex form accepts the following key-value pairs in any order:
/// ```ignore
/// generate_api!(
/// spec = "path/to/spec.json"
/// spec = "path/to/spec.json",
/// [ inner_type = path::to:Type, ]
/// [ pre_hook = closure::or::path::to::function, ]
/// [ post_hook = closure::or::path::to::function, ]