Swashbuckle MapType<Type> doesn't work with parameters

筅森魡賤 提交于 2019-12-02 07:20:14

问题


I've got an API endpoint that takes a ShortGuid class as a parameter, like such:

[HttpGet("api/endpoint")]
public async Task<IActionResult> GetTablesAsync(ShortGuid id){}

Generates a swagger definition of:

"parameters":[
    {
        "name":"guid",
        "in":"query",
        "required":false,
        "type":"string",
        "format":"uuid"
    },
    {
        "name":"value",
        "in":"query",
        "required":false,
        "type":"string"
    }
],

I need to treat that parameter as a string, not a ShortGuid object. I already have a JsonConverter for the type that works fine, but Swashbuckle doesn't understand it so my schema is incorrect (and this my swagger-js client doesnt work). I thought MapType<> would work however that seems to only affect response objects as the schema still treats it as a ShortGuid.

c.MapType<ShortGuid>(() => new Schema { Type = "string" });

Will I require an ISchemaFilter to do this? And if so, how do I go about writing it (tried multiple attempts but no success)

来源:https://stackoverflow.com/questions/52068622/swashbuckle-maptypetype-doesnt-work-with-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!