shani klein
shani klein

Reputation: 344

Change Response Class property's naming in Swagger

I'm using Swagger and using the display of Response Class. my Controller class looks like this

    [SwaggerResponse((int)HttpStatusCode.OK, typeof(ICollection<FileVerdict>))]
    public async Task<IActionResult> GetUnsafeFiles(Guid scanId)
    {
            ICollection<FileVerdict> response = await _managementOperations.GetUnsafeFiles(scanId);
            return Ok(response);                       
        }
    }

FileVerdict Class looks like:

public class FileVerdict
{
       public string SHA256 { get; set; }
}

So the property in the Response Class should be written all with UpperCase ("SHA256"), but instead it looked like "shA256" .

Swagger Display:

Swagger Display

Upvotes: 2

Views: 514

Answers (1)

AdaTheDev
AdaTheDev

Reputation: 147374

Try marking the FileVerdict class with the attributes shown below:

[DataContract]
public class FileVerdict 
{
    [DataMember(Name = "SHA256")]
    public string SHA256 { get;set; }
}

Upvotes: 3

Related Questions