2
필자는 내 컨트롤러에서 param을 옵션으로 만들고 싶지만 필요에 따라 swagger가이를 보여줍니다. 나는이 같은 기본 값으로 변경하려고Swashbuckle의 매개 변수를 선택 사항으로 지정하십시오 (필수 항목은 아닙니다)
[HttpGet("{name}")]
[SwaggerResponse((int)HttpStatusCode.OK)]
[SwaggerResponse((int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> GetPolicy(string name)
{
if (string.IsNullOrEmpty(name))
{
return BadRequest("Name is empty");
}
try
{
CRUDPolicyResponse crudPolicyResponse = await _managementOperations.CRUDPolicy(CRUDType.Read, name, null);
if (!crudPolicyResponse.OperationSucceeded)
{
return StatusCode((int)HttpStatusCode.BadRequest, crudPolicyResponse.Message);
}
if (crudPolicyResponse.FileMetadataPolicy == null)
{
return NotFound($"Policy name doesn't exists NAME: {name}");
}
return Ok(crudPolicyResponse.FileMetadataPolicy);
}
catch (Exception ex)
{
_log.Error("Error while trying to save file meta data policy", ex);
return StatusCode((int)HttpStatusCode.InternalServerError, ex);
}
}
: 같은
내 컨트롤러 보이는 string name = null
있지만 작동하지 않는/
그래서 이름 문자열이 필요하고 내가 얻을 수 없습니다 이름이 비어있다.
나는이 솔루션 make int as nullable
가능한 복제 [Swashbuckle 자신감 UI : 제거하는 방법에 주석 XML의 매개 변수에서 필수] (https://stackoverflow.com/questions/44293438/swashbuckle -swagger-ui-how-to-remove-from-parameters-in-xml-commenting) – Helen
필자는이 솔루션을 시도했지만 작동하지 않았다는 것을 썼습니다. "이 솔루션으로 내 문제를 해결하려고했습니다. int nullable " –
그 답에서 다른 2 가지 해결책을 시도 했습니까? – Helen