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

Utoipa for the solvers crate #2668

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 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
11 changes: 11 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
- run: cargo build -p openapi-generator
- name: Check for unstaged changes in generated YAML files
run: |
git diff --exit-code crates/solvers/openapi.yml || { echo "::error ::OpenAPI spec contains changes: crates/solvers/openapi.yml"; exit 1; }
- run: npm install @apidevtools/swagger-cli
- run: node_modules/.bin/swagger-cli validate crates/orderbook/openapi.yml
- run: node_modules/.bin/swagger-cli validate crates/driver/openapi.yml
Expand Down
80 changes: 80 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions crates/openapi-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "openapi-generator"
version = "0.1.0"
authors = ["Cow Protocol Developers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]

[build-dependencies]
solvers = { path = "../solvers" }
13 changes: 13 additions & 0 deletions crates/openapi-generator/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Trick to generate the OpenAPI spec on build time.
// See: https://github.com/juhaku/utoipa/issues/214#issuecomment-1179589373

use std::fs;

const SOLVERS_OPENAPI_PATH: &str = "../solvers/openapi.yml";

fn main() {
let openapi_yaml = solvers::generate_openapi_yaml()
.expect("Error generating the solvers OpenAPI documentation");
fs::write(SOLVERS_OPENAPI_PATH, openapi_yaml)
.expect("Error writing the solvers OpenAPI documentation");
}
1 change: 1 addition & 0 deletions crates/openapi-generator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions crates/solvers-dto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ chrono = { workspace = true }
hex = { workspace = true }
number = { path = "../number" }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
utoipa = { version = "4.2.0" }
web3 = { workspace = true }
Loading
Loading