Allow for parameters in content types (#430)
This commit is contained in:
parent
d329bc0912
commit
24862f92e0
|
@ -126,7 +126,8 @@ impl FromStr for BodyContentType {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
match s {
|
let offset = s.find(';').unwrap_or(s.len());
|
||||||
|
match &s[..offset] {
|
||||||
"application/octet-stream" => Ok(Self::OctetStream),
|
"application/octet-stream" => Ok(Self::OctetStream),
|
||||||
"application/json" => Ok(Self::Json),
|
"application/json" => Ok(Self::Json),
|
||||||
"application/x-www-form-urlencoded" => Ok(Self::FormUrlencoded),
|
"application/x-www-form-urlencoded" => Ok(Self::FormUrlencoded),
|
||||||
|
@ -455,8 +456,11 @@ impl Generator {
|
||||||
// content type of the response just as it currently examines
|
// content type of the response just as it currently examines
|
||||||
// the status code.
|
// the status code.
|
||||||
let typ = if let Some(mt) =
|
let typ = if let Some(mt) =
|
||||||
response.content.get("application/json")
|
response.content.iter().find_map(|(x, v)| {
|
||||||
{
|
(x == "application/json"
|
||||||
|
|| x.starts_with("application/json;"))
|
||||||
|
.then_some(v)
|
||||||
|
}) {
|
||||||
assert!(mt.encoding.is_empty());
|
assert!(mt.encoding.is_empty());
|
||||||
|
|
||||||
let typ = if let Some(schema) = &mt.schema {
|
let typ = if let Some(schema) = &mt.schema {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"enum": [
|
"enum": [
|
||||||
null
|
null
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/Task"
|
"$ref": "#/components/schemas/Task"
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"title": "Array_of_Task",
|
"title": "Array_of_Task",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
"operationId": "task_submit",
|
"operationId": "task_submit",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/TaskSubmit"
|
"$ref": "#/components/schemas/TaskSubmit"
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
"201": {
|
"201": {
|
||||||
"description": "successful creation",
|
"description": "successful creation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/TaskSubmitResult"
|
"$ref": "#/components/schemas/TaskSubmitResult"
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"title": "Array_of_TaskEvent",
|
"title": "Array_of_TaskEvent",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -168,7 +168,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"title": "Array_of_TaskOutput",
|
"title": "Array_of_TaskOutput",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -213,7 +213,7 @@
|
||||||
"operationId": "user_create",
|
"operationId": "user_create",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UserCreate"
|
"$ref": "#/components/schemas/UserCreate"
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@
|
||||||
"201": {
|
"201": {
|
||||||
"description": "successful creation",
|
"description": "successful creation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UserCreateResult"
|
"$ref": "#/components/schemas/UserCreateResult"
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WhoamiResult"
|
"$ref": "#/components/schemas/WhoamiResult"
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
"operationId": "worker_bootstrap",
|
"operationId": "worker_bootstrap",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerBootstrap"
|
"$ref": "#/components/schemas/WorkerBootstrap"
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@
|
||||||
"201": {
|
"201": {
|
||||||
"description": "successful creation",
|
"description": "successful creation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerBootstrapResult"
|
"$ref": "#/components/schemas/WorkerBootstrapResult"
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerPingResult"
|
"$ref": "#/components/schemas/WorkerPingResult"
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerAppendTask"
|
"$ref": "#/components/schemas/WorkerAppendTask"
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@
|
||||||
"201": {
|
"201": {
|
||||||
"description": "successful creation",
|
"description": "successful creation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/UploadedChunk"
|
"$ref": "#/components/schemas/UploadedChunk"
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerCompleteTask"
|
"$ref": "#/components/schemas/WorkerCompleteTask"
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkerAddOutput"
|
"$ref": "#/components/schemas/WorkerAddOutput"
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "successful operation",
|
"description": "successful operation",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json; charset=utf-8": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/WorkersResult"
|
"$ref": "#/components/schemas/WorkersResult"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue