Skip to content

Commit 34500b3

Browse files
committed
feat: 0.1.85 rust - generator config
1 parent 0fd7464 commit 34500b3

6 files changed

Lines changed: 51 additions & 22 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"lint": "scalar validate ./src/definitions.yaml",
1818
"bundle": "yarn redocly bundle -o ./blockfrost-openapi.yaml src/definitions.yaml && yarn openapi-merge-cli && yarn redocly bundle -o ./openapi.json ./openapi.yaml && yarn copy-spec",
1919
"generate-types": "yarn openapi-typescript ./openapi.yaml --output ./src/generated-types.ts",
20-
"generate-types:rust": "openapi-generator-cli generate -i openapi.yaml -g rust -o ./rust --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles",
20+
"generate-types:rust": "openapi-generator-cli generate -i openapi.yaml -g rust -o ./rust -c rust/openapi-generator.json --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles && node rust/fix-cargo.js",
2121
"generate-json-schema": "node lib/scripts/generate-json-schema.js > json-schema.json",
2222
"sync-version": "ts-node ./src/scripts/sync-version.ts",
2323
"test": "vitest",

rust/Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
name = "blockfrost-openapi"
33
version = "0.1.85"
44
authors = ["contact@blockfrost.io"]
5-
description = "Blockfrost is an API as a service that allows users to interact with the Cardano blockchain and parts of its ecosystem."
5+
description = "Blockfrost OpenAPI types for Cardano"
66
license = "MIT"
77
edition = "2021"
88

99
[dependencies]
1010
serde = { version = "^1.0", features = ["derive"] }
11-
serde_with = { version = "^3.8", default-features = false, features = [
12-
"base64",
13-
"std",
14-
"macros",
15-
] }
11+
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
1612
serde_json = "^1.0"
1713
serde_repr = "^0.1"
1814
url = "^2.5"

rust/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rust API client for openapi
1+
# Rust API client for blockfrost-openapi
22

33
Blockfrost is an API as a service that allows users to interact with the Cardano blockchain and parts of its ecosystem.
44

@@ -222,10 +222,10 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
222222

223223
## Installation
224224

225-
Put the package under your project folder in a directory named `openapi` and add the following to `Cargo.toml` under `[dependencies]`:
225+
Put the package under your project folder in a directory named `blockfrost-openapi` and add the following to `Cargo.toml` under `[dependencies]`:
226226

227227
```
228-
openapi = { path = "./openapi" }
228+
blockfrost-openapi = { path = "./blockfrost-openapi" }
229229
```
230230

231231
## Documentation for API Endpoints
@@ -417,3 +417,7 @@ To get access to the crate's generated documentation, use:
417417
```
418418
cargo doc --open
419419
```
420+
421+
## Author
422+
423+

rust/fix-cargo.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const config = JSON.parse(
5+
fs.readFileSync(path.join(__dirname, "openapi-generator.json"), "utf-8")
6+
);
7+
8+
const cargoPath = path.join(__dirname, "Cargo.toml");
9+
let cargo = fs.readFileSync(cargoPath, "utf-8");
10+
11+
if (config.packageDescription) {
12+
cargo = cargo.replace(
13+
/^description = ".*"$/m,
14+
`description = "${config.packageDescription}"`
15+
);
16+
}
17+
18+
if (config.packageName) {
19+
cargo = cargo.replace(
20+
/^name = ".*"$/m,
21+
`name = "${config.packageName}"`
22+
);
23+
}
24+
25+
fs.writeFileSync(cargoPath, cargo);

rust/openapi-generator.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"packageName": "blockfrost-openapi",
3+
"packageDescription": "Blockfrost OpenAPI types for Cardano"
4+
}

0 commit comments

Comments
 (0)