Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): added crate with generated with api #257

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build and publish rust crate
name: Rust

on:
push:
branches: [ main ]

jobs:
release:
name: Rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
path: crates/openapi-client
check-repo: true
ignore-unpublished-changes: true
dry-run: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ dist/
/exports
www/venv
www/.cache

Cargo.lock
target
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[workspace]
members = ["crates/openapi-client"]
resolver = "2"
edition = "2021"
23 changes: 23 additions & 0 deletions crates/openapi-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "process-compose-openapi-client"
version = "1.40.1"
description = "OpenAPI client for Process Compose"
license = "Apache-2.0"
edition = "2021"
[dependencies]
progenitor-client = { version = "^0.8.0" }
reqwest = { version = "^0.12.9", default-features = false, features = [
"json",
"stream",
] }
serde = { version = "^1.0.42", default-features = false, features = ["derive"] }
serde_json = { version = "^1.0.42", default-features = false }

[dev-dependencies]
tokio = { version = "^1.41", features = ["macros"] }

[build-dependencies]
progenitor = { version = "^0.8.0" }
syn = { version = "^2.0.85" }
prettyplease = { version = "^0.2.25" }
serde_json = { version = "^1.0.42", default-features = false }
13 changes: 13 additions & 0 deletions crates/openapi-client/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main() {
let src = "swagger.json";
println!("cargo:rerun-if-changed={}", src);
let spec = include_str!("swagger.json");
let spec = serde_json::from_str(spec).unwrap();
let mut generator = progenitor::Generator::default();
let tokens = generator.generate_tokens(&spec).unwrap();
let ast = syn::parse2(tokens).unwrap();
let content = prettyplease::unparse(&ast);
let mut out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
out_file.push("lib.rs");
std::fs::write(out_file, content).unwrap();
}
1 change: 1 addition & 0 deletions crates/openapi-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
Loading