0
mediatype을 application/octet-stream으로 생성하는 엔드 포인트가 있습니다. 그러나 swagger json을 생성하면 "produce/json"으로 "produce"가 지정됩니다. 특별한 구성을 사용하지 않았습니다. 내가 한 모든 것은 swagger nuget을 가져 와서 그대로 기본 구성을 유지했습니다.swashbuckle mediatype application/octetstream
[HttpPost]
[Route("document/method1")]
public HttpResponseMessage method1([FromBody]SomeModel SomeModelValue)
{
// code that generates the file
if (File.Exists(outputFilePath))
{
byte[] resultFile = File.ReadAllBytes(outputFilePath);
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Created);
response.Content = new ByteArrayContent(ResultFile);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue(ContentDispositionHeaderValue);
response.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeHeaderValue);
response.Content.Headers.ContentLength = ResultFile.Length;
File.Delete(inputFilePath);
File.Delete(outputFilePath);
return response;
}
else
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
}
을 그리고 자신감에서 jsonSchema : 엔드 포인트를 검색
"/document/method1": {
"post": {
"tags": ["Document"],
"operationId": "Document_Method1",
"consumes": ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"],
"produces": ["application/json", "text/json", "application/xml", "text/xml"],
"parameters": [{
"name": "SomeModelValue",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SomeModel"
}
}],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object"
}
}
}
}
}
그것은 [도움] 수 있습니다 (https://stackoverflow.com/questions/34990291/swashbuckle-swagger- 재 작업 샘플입니다 how-to-annotate-content-types) –
이반에게 올바른 글을 알려 주셔서 감사합니다. 죄송합니다. 나는 그것을 놓쳤으며 아마도 질문을 복제했습니다. 어쨌든 고마워. 도움이되었습니다. – Rajagopal