Skip to content

Commit 95e92cf

Browse files
committed
!
1 parent 3b3140c commit 95e92cf

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

crates/rustapi-core/tests/snapshot_test.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustapi_core::{post, Created, Json, RustApi, get};
1+
use rustapi_core::{get, post, Created, Json, RustApi};
22
use rustapi_openapi::Schema;
33
use serde::{Deserialize, Serialize};
44
use serde_json::json;
@@ -211,34 +211,34 @@ async fn test_openapi_snapshot() {
211211
assert_eq!(output, output2, "Nondeterministic output detected!");
212212
}
213213

214-
#[derive(Debug, Deserialize, Schema)]
215-
struct CreatePin {
214+
#[derive(Debug, Deserialize, Schema)]
215+
struct CreatePin {
216216
title: String,
217-
}
217+
}
218218

219-
#[derive(Debug, Serialize, Schema)]
220-
struct PinResponse {
219+
#[derive(Debug, Serialize, Schema)]
220+
struct PinResponse {
221221
id: i64,
222222
title: String,
223-
}
223+
}
224224

225-
async fn create_pin(Json(body): Json<CreatePin>) -> Created<PinResponse> {
225+
async fn create_pin(Json(body): Json<CreatePin>) -> Created<PinResponse> {
226226
Created(PinResponse {
227-
id: 1,
228-
title: body.title,
227+
id: 1,
228+
title: body.title,
229229
})
230-
}
230+
}
231231

232-
#[test]
233-
fn test_manual_route_registers_openapi_components_for_body_refs() {
232+
#[test]
233+
fn test_manual_route_registers_openapi_components_for_body_refs() {
234234
use rustapi_openapi::schema::RustApiSchema;
235235

236236
let app = RustApi::new().route("/pins", post(create_pin));
237237
let spec = app.openapi_spec();
238238

239239
assert!(
240-
spec.validate_integrity().is_ok(),
241-
"manual route OpenAPI spec should not contain dangling $ref values"
240+
spec.validate_integrity().is_ok(),
241+
"manual route OpenAPI spec should not contain dangling $ref values"
242242
);
243243

244244
let components = spec.components.as_ref().expect("components should exist");
@@ -251,15 +251,15 @@ async fn test_openapi_snapshot() {
251251
let path_item = spec.paths.get("/pins").expect("/pins path should exist");
252252
let op = path_item.post.as_ref().expect("POST /pins should exist");
253253
let media_type = op
254-
.request_body
255-
.as_ref()
256-
.and_then(|body| body.content.get("application/json"))
257-
.expect("request body media type should exist");
254+
.request_body
255+
.as_ref()
256+
.and_then(|body| body.content.get("application/json"))
257+
.expect("request body media type should exist");
258258

259259
match media_type.schema.as_ref().expect("schema should exist") {
260-
rustapi_openapi::SchemaRef::Ref { reference } => {
261-
assert_eq!(reference, "#/components/schemas/CreatePin");
262-
}
263-
other => panic!("expected request body schema ref, got {other:?}"),
260+
rustapi_openapi::SchemaRef::Ref { reference } => {
261+
assert_eq!(reference, "#/components/schemas/CreatePin");
262+
}
263+
other => panic!("expected request body schema ref, got {other:?}"),
264264
}
265-
}
265+
}

crates/rustapi-openapi/src/spec.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ impl OpenApiSpec {
5858
version: version.into(),
5959
..Default::default()
6060
},
61-
json_schema_dialect: Some(
62-
"https://spec.openapis.org/oas/3.1/dialect/base".to_string(),
63-
),
61+
json_schema_dialect: Some("https://spec.openapis.org/oas/3.1/dialect/base".to_string()),
6462
servers: Vec::new(),
6563
paths: BTreeMap::new(),
6664
webhooks: BTreeMap::new(),

0 commit comments

Comments
 (0)