-
Notifications
You must be signed in to change notification settings - Fork 117
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
add #[openapi(rename = "...")] attribute #367
add #[openapi(rename = "...")] attribute #367
Conversation
So the tests basically take your "config", generate the openapi spec and compare it against a hardcoded spec using Example: #[test]
fn test_rename_api() {
#[derive(Deserialize, Serialize, Apiv2Schema)]
#[serde(rename_all = "camelCase")]
/// Pets are awesome!
struct Pet {
/// Pick a good one.
name: String,
}
#[get("/pets")]
#[api_v2_operation]
fn echo_pets() -> impl Future<Output = Result<web::Json<Vec<Pet>>, Error>> {
fut_ok(web::Json(vec![]))
}
run_and_check_app(
|| {
App::new()
.wrap_api()
.service(echo_pets)
.with_raw_json_spec(|app, spec| {
app.route(
"/api/spec",
web::get().to(move || actix_web::HttpResponse::Ok().json(&spec)),
)
})
.build()
},
|addr| {
let resp = CLIENT
.get(&format!("http://{}/api/spec", addr))
.send()
.expect("request failed?");
check_json(
resp,
json!({
"definitions": {
"Pet": {
"description": "Pets are awesome!",
"properties": {
"name": {
"description": "Pick a good one.",
"type": "string"
},
},
"required":[
"name"
],
"type":"object"
}
},
"info": {
"title":"",
"version":""
},
"paths": {
"/pets": {
"get": {
"responses": {
"200": {
"description": "OK",
"schema": {
"items": {
"$ref": "#/definitions/Pet"
},
"type": "array"
}
}
},
}
}
},
"swagger": "2.0"
}),
);
},
);
} |
7bc30d0
to
bce9c35
Compare
Hey @tiagolobocastro, I rebased, reimplemented |
awesome thanks @tomsik68, I've kicked gh actions and will try to have a look during the week |
Thank you @tomsik68 ! |
Hello!
I designed a fix for #357 which is a little different from the approach in #358. This time, I'm adding the explicit rename using
#[openapi(rename = "...")]
. If there's a good way to test my approach using existing paperclip tests, I'd love to know about it.