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

Solvers JSON OpenAPI schema #2683

Merged
merged 1 commit into from
May 2, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ jobs:
- 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; }
git diff --exit-code crates/solvers/openapi.json || { echo "::error ::OpenAPI spec contains changes: crates/solvers/openapi.json"; 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
- run: node_modules/.bin/swagger-cli validate crates/solvers/openapi.yml
- run: node_modules/.bin/swagger-cli validate crates/orderbook/openapi.json
- run: node_modules/.bin/swagger-cli validate crates/driver/openapi.json
- run: node_modules/.bin/swagger-cli validate crates/solvers/openapi.json
21 changes: 0 additions & 21 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/openapi-generator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use std::fs;

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

fn main() {
let openapi_yaml = solvers::generate_openapi_yaml()
let openapi_yaml = solvers::generate_openapi_json()
.expect("Error generating the solvers OpenAPI documentation");
fs::write(SOLVERS_OPENAPI_PATH, openapi_yaml)
.expect("Error writing the solvers OpenAPI documentation");
Expand Down
10 changes: 7 additions & 3 deletions crates/solvers-dto/src/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ pub struct Decimal(String);
/// A hex-encoded 32 byte string containing the pool address (0..20), the pool
/// specialization (20..22) and the poolnonce (22..32).
#[derive(ToSchema)]
#[schema(example = "0xc88c76dd8b92408fe9bea1a54922a31")]
#[schema(example = "0xc88c76dd8b92408fe9bea1a54922a31e232d873c0002000000000000000005b2")]
#[allow(dead_code)]
pub struct BalancerPoolId(String);

Expand Down Expand Up @@ -728,13 +728,17 @@ pub struct I32(String);
/// represent the owner address and bytes [52, 56) represent the order's
/// `validTo` field.
#[derive(ToSchema)]
#[schema(example = "0x30cff40d9f60caa68a37f0ee73253ad")]
#[schema(
example = "0x30cff40d9f60caa68a37f0ee73253ad6ad72b45580c945fe3ab67596476937197854163b1b0d24e77dca702b97b5cc33e0f83dcb626122a6"
)]
#[allow(dead_code)]
pub struct OrderUid(String);

/// Signature bytes.
#[derive(ToSchema)]
#[schema(example = "0x0000000000000000000000000000000")]
#[schema(
example = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use proper examples not default values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will address it in the main PR.

)]
#[allow(dead_code)]
pub struct Signature(String);

Expand Down
10 changes: 6 additions & 4 deletions crates/solvers-dto/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ use utoipa::ToSchema;

/// Signature bytes.
#[derive(ToSchema)]
#[schema(example = "0x0000000000000000000000000000000")]
#[schema(
example = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
)]
#[allow(dead_code)]
pub struct Signature(String);

/// 32 bytes of arbitrary application specific data that can be added to an
/// order. This can also be used to ensure uniqueness between two orders with
/// otherwise the exact same parameters.
#[derive(ToSchema)]
#[schema(example = "0x0000000000000000000000000000000")]
#[schema(example = "0x0000000000000000000000000000000000000000000000000000000000000000")]
#[allow(dead_code)]
pub struct AppData(String);

Expand All @@ -24,12 +26,12 @@ pub struct TokenAmount(String);

/// An Ethereum public address.
#[derive(ToSchema)]
#[schema(example = "0x0000000000000000000000000000000")]
#[schema(example = "0x0000000000000000000000000000000000000000")]
#[allow(dead_code)]
pub struct Address(String);

/// An ERC20 token address.
#[derive(ToSchema)]
#[schema(example = "0xDEf1CA1fb7FBcDC777520aa7f396b4E")]
#[schema(example = "0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB")]
#[allow(dead_code)]
pub struct Token(String);
3 changes: 1 addition & 2 deletions crates/solvers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ reqwest = { workspace = true }
s3 = { path = "../s3" }
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = "0.9.34+deprecated"
serde_with = { workspace = true }
solvers-dto = { path = "../solvers-dto" }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal", "time"] }
toml = { workspace = true }
tower = "0.4"
tower-http = { version = "0.4", features = ["limit", "trace"] }
utoipa = { version = "4.2.0", features = ["yaml", "axum_extras"] }
utoipa = { version = "4.2.0", features = ["axum_extras"] }
web3 = { workspace = true }

# TODO Once solvers are ported and E2E tests set up, slowly migrate code and
Expand Down
Loading
Loading