Skip to content

Commit

Permalink
refactor use order, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kilork committed Aug 18, 2023
1 parent 0e481f6 commit 6ebcccb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions examples/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,14 @@ fn read_methods_info(
}

fn write_types(enums: &[EnumType], structs: &[Rc<StructType>]) {
println!("use std::collections::HashMap;\n");
println!();
println!(r#"#[cfg(feature = "schemars")]"#);
println!("use schemars::JsonSchema;");
println!("use serde::{{Deserialize, Serialize}};");
println!("use serde_json::Value;");
println!("use serde_with::skip_serializing_none;");
println!("use std::collections::HashMap;\n");
println!();

for e in enums {
println!("#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]");
Expand Down Expand Up @@ -404,10 +406,13 @@ fn process_method_parameters(
fn write_rest(methods: &[MethodStruct], stream_mapping: &HashMap<String, String>) {
let keycloak_version =
std::env::var("KEYCLOAK_VERSION").expect("environment variable KEYCLOAK_VERSION");
println!("use serde_json::{{json, Value}};");
println!("use std::collections::HashMap;\n");
println!("use reqwest::header::CONTENT_LENGTH;\n");
println!("use super::*;\n");
println!("use std::collections::HashMap;");
println!();
println!("use reqwest::header::CONTENT_LENGTH;");
println!("use serde_json::Value;");
println!();
println!("use super::*;");
println!();
println!("impl<TS: KeycloakTokenSupplier> KeycloakAdmin<TS> {{");

for method in methods {
Expand Down
5 changes: 3 additions & 2 deletions src/rest/generated_rest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde_json::{Value};
use std::collections::HashMap;

use reqwest::header::CONTENT_LENGTH;
use serde_json::Value;

use super::*;

Expand Down Expand Up @@ -2162,7 +2163,7 @@ impl<TS: KeycloakTokenSupplier> KeycloakAdmin<TS> {
"{}/admin/realms/{realm}/clients/{id}/default-client-scopes/{client_scope_id}",
self.url
))
.header( CONTENT_LENGTH, "0")
.header(CONTENT_LENGTH, "0")
.bearer_auth(self.token_supplier.get(&self.url).await?);
let response = builder.send().await?;
error_check(response).await?;
Expand Down
3 changes: 2 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::HashMap;

#[cfg(feature = "schemars")]
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_with::skip_serializing_none;
use std::collections::HashMap;

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
Expand Down

0 comments on commit 6ebcccb

Please sign in to comment.