Skip to content
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
25 changes: 25 additions & 0 deletions Cargo.lock

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

10 changes: 9 additions & 1 deletion dropshot/src/api_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct ApiEndpoint<Context: ServerContext> {
pub path: String,
pub parameters: Vec<ApiEndpointParameter>,
pub response: ApiEndpointResponse,
pub summary: Option<String>,
pub description: Option<String>,
pub tags: Vec<String>,
pub paginated: bool,
Expand Down Expand Up @@ -63,13 +64,19 @@ impl<'a, Context: ServerContext> ApiEndpoint<Context> {
path: path.to_string(),
parameters: func_parameters.parameters,
response,
summary: None,
description: None,
tags: vec![],
paginated: func_parameters.paginated,
visible: true,
}
}

pub fn summary<T: ToString>(mut self, description: T) -> Self {
self.summary.replace(description.to_string());
self
}

pub fn description<T: ToString>(mut self, description: T) -> Self {
self.description.replace(description.to_string());
self
Expand Down Expand Up @@ -465,6 +472,7 @@ impl<Context: ServerContext> ApiDescription<Context> {
};
let mut operation = openapiv3::Operation::default();
operation.operation_id = Some(endpoint.operation_id.clone());
operation.summary = endpoint.summary.clone();
operation.description = endpoint.description.clone();
operation.tags = endpoint.tags.clone();

Expand Down Expand Up @@ -812,7 +820,7 @@ fn j2oas_schema_object(
(None, None) => {
openapiv3::SchemaKind::Any(openapiv3::AnySchema::default())
}
_ => panic!("invalid"),
_ => panic!("invalid {:#?}", obj),
};

let mut data = openapiv3::SchemaData::default();
Expand Down
1 change: 1 addition & 0 deletions dropshot/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ mod test {
success: None,
description: None,
},
summary: None,
description: None,
tags: vec![],
paginated: false,
Expand Down
6 changes: 4 additions & 2 deletions dropshot/tests/test_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@
},
"/test/person": {
"get": {
"description": "This is a multi-line comment. It uses Rust-style.",
"summary": "Rust style comment",
"description": "This is a multi-line comment.",
"operationId": "handler1",
"responses": {
"200": {
Expand Down Expand Up @@ -328,7 +329,8 @@
},
"/test/woman": {
"put": {
"description": "This is a multi-line comment. It uses C-style.",
"summary": "C-style comment",
"description": "This is a multi-line comment.",
"operationId": "handler2",
"parameters": [
{
Expand Down
6 changes: 4 additions & 2 deletions dropshot/tests/test_openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use std::{io::Cursor, str::from_utf8, sync::Arc};
method = GET,
path = "/test/person",
}]
/// Rust style comment
///
/// This is a multi-
/// line comment.
/// It uses Rust-style.
async fn handler1(
_rqctx: Arc<RequestContext<()>>,
) -> Result<HttpResponseOk<()>, HttpError> {
Expand All @@ -36,9 +37,10 @@ struct QueryArgs {
path = "/test/woman",
}]
/**
* C-style comment
*
* This is a multi-
* line comment.
* It uses C-style.
*/
async fn handler2(
_rqctx: Arc<RequestContext<()>>,
Expand Down
6 changes: 4 additions & 2 deletions dropshot/tests/test_openapi_fuller.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@
},
"/test/person": {
"get": {
"description": "This is a multi-line comment. It uses Rust-style.",
"summary": "Rust style comment",
"description": "This is a multi-line comment.",
"operationId": "handler1",
"responses": {
"200": {
Expand Down Expand Up @@ -336,7 +337,8 @@
},
"/test/woman": {
"put": {
"description": "This is a multi-line comment. It uses C-style.",
"summary": "C-style comment",
"description": "This is a multi-line comment.",
"operationId": "handler2",
"parameters": [
{
Expand Down
7 changes: 5 additions & 2 deletions dropshot_endpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ proc-macro = true
[dependencies]
proc-macro2 = "1"
quote = "1"
serde_tokenstream = "0.1.3"
serde_tokenstream = "0.1"

[dependencies.serde]
version = "1.0"
features = [ "derive" ]

[dependencies.syn]
version = "1.0.85"
version = "1.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is basically unrelated: I'm all for this but FYI I think it's dependabot that's replacing these with more specific versions when it updates deps. It doesn't always do this and I'm not sure exactly when it does. If the Renovate experiment goes well I hope it will give us more control over this.

features = [ "parsing", "printing" ]

[dev-dependencies]
schema = "0.0.1"
Loading