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
21 changes: 19 additions & 2 deletions dropshot/src/api_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,15 +778,32 @@ impl<Context: ServerContext> ApiDescription<Context> {
} else {
// If no schema was specified, the response is hand-rolled. In
// this case we'll fall back to the default response type which
// we assume to be inclusive of errors.
// we assume to be inclusive of errors. The media type and
// and schema will similarly be maximally permissive.
let mut content = indexmap::IndexMap::new();
content.insert(
"*/*".to_string(),
openapiv3::MediaType {
schema: Some(openapiv3::ReferenceOr::Item(
openapiv3::Schema {
schema_data: openapiv3::SchemaData::default(),
schema_kind: openapiv3::SchemaKind::Any(
openapiv3::AnySchema::default(),
),
},
)),
..Default::default()
},
);
operation.responses.default =
Some(openapiv3::ReferenceOr::Item(openapiv3::Response {
// TODO: perhaps we should require even free-form
// responses to have a description since it's required
// by OpenAPI.
description: "".to_string(),
content,
..Default::default()
}))
}));
}

// Drop in the operation.
Expand Down
7 changes: 6 additions & 1 deletion dropshot/tests/test_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,12 @@
"operationId": "handler16",
"responses": {
"default": {
"description": ""
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion dropshot/tests/test_openapi_fuller.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,12 @@
"operationId": "handler16",
"responses": {
"default": {
"description": ""
"description": "",
"content": {
"*/*": {
"schema": {}
}
}
}
}
}
Expand Down