Skip to content

Commit

Permalink
Merge pull request #17 from Sindri-Labs/klm-update-client-plus-patches
Browse files Browse the repository at this point in the history
Update openapi, use original spec, reformat patches
  • Loading branch information
katiemckeon authored Feb 26, 2025
2 parents c2c1882 + 8a01380 commit 06b7b09
Show file tree
Hide file tree
Showing 133 changed files with 2,713 additions and 1,887 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion openapi/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ README.md
git_push.sh
.travis.yml
docs/
openapi.patch
patches/
14 changes: 11 additions & 3 deletions openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ Cargo.toml
src/apis/authorization_api.rs
src/apis/circuits_api.rs
src/apis/configuration.rs
src/apis/internal_api.rs
src/apis/mod.rs
src/apis/proofs_api.rs
src/apis/token_api.rs
src/lib.rs
src/models/action_response.rs
src/models/api_key_does_not_exist_response.rs
Expand All @@ -23,11 +25,9 @@ src/models/circuit_status_response.rs
src/models/circuit_type.rs
src/models/coming_soon_response.rs
src/models/exception_id.rs
src/models/forge_internal_error_response.rs
src/models/forge_invalid_upload_response.rs
src/models/forge_value_error_response.rs
src/models/gnark_circuit_info_response.rs
src/models/halo2_circuit_info_response.rs
src/models/hermez_circuit_info_response.rs
src/models/input.rs
src/models/job_status.rs
src/models/jolt_circuit_info_response.rs
Expand All @@ -54,13 +54,21 @@ src/models/proof_info_response.rs
src/models/proof_input.rs
src/models/proof_list_input.rs
src/models/proof_status_response.rs
src/models/sindri_internal_error_response.rs
src/models/sindri_invalid_upload_response.rs
src/models/sindri_value_error_response.rs
src/models/smart_contract_verifier_response.rs
src/models/snarkvm_circuit_info_response.rs
src/models/sp1_circuit_info_response.rs
src/models/team_already_exists_response.rs
src/models/team_create_input.rs
src/models/team_detail.rs
src/models/team_does_not_exist_response.rs
src/models/team_invite_input.rs
src/models/team_me_response.rs
src/models/team_member_detail.rs
src/models/team_members_response.rs
src/models/team_remove_member_input.rs
src/models/token_obtain_pair_input_schema.rs
src/models/token_obtain_pair_output_schema.rs
src/models/token_refresh_input_schema.rs
Expand Down
2 changes: 1 addition & 1 deletion openapi/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.10.0
7.11.0
4 changes: 2 additions & 2 deletions openapi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "openapi"
version = "1.15.1"
version = "1.17.6"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
description = " ## About [Sindri Labs](https://www.sindri.app/)' API simplifies the developer experience to enable fast and scalable zero-knowledge proof generation. Front-End Dashboard: [https://sindri.app/login](https://sindri.app/login) ## Documentation The [Sindri Documentation](https://sindri.app/docs) contains everything you need to get started! ## Sindri Resources The [sindri-resources GitHub repo](https://github.com/Sindri-Labs/sindri-resources) contains contains resources and sample data for the Sindri API. ## Using this Page This is a standard [OpenAPI (Swagger)](https://swagger.io/specification/) API documentation page. It provides detailed documentation for each endpoint. This page enables easy prototyping via the \"Try it out\" feature! Since all Sindri endpoints require a valid API Key, in order to use the \"Try it out\" feature for any endpoint in this documentation you must first obtain an API key. Do this in one of two ways: 1. Enter your username and password in the `/api/apikey/generate` endpoint of the **Authorization** section below. Use the API key returned in the `access` field of the response. 2. Obtain an API key from the Sindri Dashboard team \"Account Settings\". After obtaining your API key, authorize your page session by entering your API Key in the `SindriAPIKeyBearerAuth` section, reached by clicking \"Authorize\" below. Proving Backend Version: v1.2.2 "
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2021"
Expand Down
159 changes: 0 additions & 159 deletions openapi/openapi.patch

This file was deleted.

18 changes: 18 additions & 0 deletions openapi/patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Manual Patches

Internal documentation.

## Patch List

Most of these patches (marked with a `*`) are temporary solutions until the openapi-generator fully supports 3.1.0 specifications.
Removing `scripts/openapitools.json` and rerunning `./scripts/update-sdk.sh` will regenerate the client with the latest rust openapi-generator version, potentially removing the need for some of these patches.

| Filename | Purpose | Patched Files |
|----------------|--------------------------|-----------------------|
| `circuit_creation.patch` | *Creates custom multipart form data | `src/apis/circuits_api.rs` |
| `define_any_ltgt.patch` | *Defines `AnyOfLessThanGreaterThan` type (as `serde_json::Value`) | `src/models/mod.rs` |
| `export_some_internals.patch` | Exports some internal types for use in `sindri-rs` | `src/apis/mod.rs` |
| `no_circuit_response_nest.patch` | Circuit info is not nested by `circuit_type`, this patch removes the nesting | `src/models/circuit_info_response.rs` |
| `rm_id_options_restore_download.patch` | *Identifiers should not be optional for path params | `src/apis/internal_api.rs` |
| `rm_proof_id_option.patch` | *Identifier should not be optional for path params | `src/apis/proofs_api.rs` |
| `two_input_modes.patch` | Allows automatic inference of proof input type from string or JSON | `src/models/proof_input.rs` |
86 changes: 86 additions & 0 deletions openapi/patches/circuit_creation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
diff --git a/openapi/src/apis/circuits_api.rs b/openapi/src/apis/circuits_api.rs
index b604ac4..96d8aad 100644
--- a/openapi/src/apis/circuits_api.rs
+++ b/openapi/src/apis/circuits_api.rs
@@ -73,7 +73,7 @@ pub enum ProofCreateError {
/// Create a circuit.
pub async fn circuit_create(
configuration: &configuration::Configuration,
- files: Vec<std::path::PathBuf>,
+ files: Vec<u8>,
meta: Option<std::collections::HashMap<String, String>>,
tags: Option<Vec<String>>,
) -> Result<models::CircuitInfoResponse, Error<CircuitCreateError>> {
@@ -96,23 +96,58 @@ pub async fn circuit_create(
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
- let mut multipart_form = reqwest::multipart::Form::new();
- // TODO: support file upload for 'files' parameter
- if let Some(param_value) = p_meta {
- multipart_form = multipart_form.text("meta", param_value.to_string());
+ // Build the request body directly in order to avoid a streaming request
+ // that is incompatible with the retry middleware
+ let boundary = "----------------------------4ebf00fbcf09";
+ req_builder = req_builder.header(
+ "Content-Type",
+ format!("multipart/form-data; boundary={boundary}"),
+ );
+
+ let filename = "rust_sdk_upload.tar.gz";
+ let mut byte_string = Vec::new();
+ byte_string.extend_from_slice(
+ format!(
+ "--{boundary}\r\n\
+ Content-Disposition: form-data; name=\"files\"; filename=\"{filename}\"\r\n\
+ \r\n",
+ )
+ .as_bytes(),
+ );
+ byte_string.extend(p_files);
+ byte_string.extend_from_slice(format!("--{boundary}--\r\n").as_bytes()); // End of files
+ if let Some(p_tags) = p_tags {
+ for tag in p_tags {
+ byte_string.extend_from_slice(
+ format!(
+ "--{boundary}\r\n\
+ Content-Disposition: form-data; name=\"tags\"\r\n\
+ \r\n\
+ {tag}\r\n"
+ )
+ .as_bytes(),
+ );
+ byte_string.extend_from_slice(format!("--{boundary}--\r\n").as_bytes());
+ // End of tag
+ }
}
- if let Some(param_value) = p_tags {
- multipart_form = multipart_form.text(
- "tags",
- param_value
- .into_iter()
- .map(|p| p.to_string())
- .collect::<Vec<String>>()
- .join(",")
- .to_string(),
+ if let Some(p_meta) = p_meta {
+ let meta_json = serde_json::to_string(&p_meta)?;
+ byte_string.extend_from_slice(
+ format!(
+ "--{boundary}\r\n\
+ Content-Disposition: form-data; name=\"meta\"\r\n\
+ Content-Type: application/json\r\n\
+ \r\n\
+ {meta_json}\r\n"
+ )
+ .as_bytes(),
);
+ byte_string.extend_from_slice(format!("--{boundary}--\r\n").as_bytes());
+ // End of meta
}
- req_builder = req_builder.multipart(multipart_form);
+ let local_var_body = reqwest::Body::from(byte_string);
+ req_builder = req_builder.body(local_var_body);

let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
9 changes: 9 additions & 0 deletions openapi/patches/define_any_ltgt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/openapi/src/models/mod.rs b/openapi/src/models/mod.rs
index ba528a7..971bc35 100644
--- a/openapi/src/models/mod.rs
+++ b/openapi/src/models/mod.rs
@@ -1,3 +1,4 @@
+pub type AnyOfLessThanGreaterThan = serde_json::Value;
pub mod action_response;
pub use self::action_response::ActionResponse;
pub mod api_key_does_not_exist_response;
17 changes: 17 additions & 0 deletions openapi/patches/export_some_internals.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/openapi/src/apis/mod.rs b/openapi/src/apis/mod.rs
index 18c0d9d..9347831 100644
--- a/openapi/src/apis/mod.rs
+++ b/openapi/src/apis/mod.rs
@@ -103,7 +103,11 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String

pub mod authorization_api;
pub mod circuits_api;
-pub mod internal_api;
+#[allow(dead_code)]
+mod internal_api;
+pub use internal_api::{
+ circuit_download, circuit_status, proof_status, CircuitStatusError, ProofStatusError,
+};
pub mod proofs_api;
pub mod token_api;

13 changes: 13 additions & 0 deletions openapi/patches/no_circuit_response_nest.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/openapi/src/models/circuit_info_response.rs b/openapi/src/models/circuit_info_response.rs
index 2f6d0d2..1b50f0b 100644
--- a/openapi/src/models/circuit_info_response.rs
+++ b/openapi/src/models/circuit_info_response.rs
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};

/// CircuitInfoResponse : Response for getting circuit info.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-#[serde(tag = "circuit_type")]
+#[serde(untagged)]
pub enum CircuitInfoResponse {
#[serde(rename = "boojum")]
Boojum(Box<models::BoojumCircuitInfoResponse>),
Loading

0 comments on commit 06b7b09

Please sign in to comment.