Swagger 查询参数模板 [英] Swagger query parameter template

查看:48
本文介绍了Swagger 查询参数模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有点复杂的查询参数,我有自己的语法来生成该值.它有多个变量来生成一个完整的字符串值.假设参数的名称是具有行和列的索引,就像使这个值 20:30

I have on query parameter which is little bit complex and i have my own syntax to make that value. Its has more then one variable to make one complete string value. Let suppose name of parameter is index which has row and column like to make this value 20:30

index =  { row: 20, col:30 }
index2 = { row: 20, col:30, chr: 15 }

现在我想把它做成

example.com?index=20:30
example.com?index2=20:30:15

有人能告诉我如何在 swagger 中定义它吗?谢谢.

Can someone tell me how can i define this in swagger ? Thank you.

推荐答案

将 swagger 参数设为字符串,并在后面的代码中处理拆分为多个变量...

Make your swagger parameter a string and in your code behind handle the splitting into multiple variables...

我就是这样做的:http://turoapi.azurewebsites.net/swagger/ui/index#/Echo/Echo_Get

"parameters": [
{
    "name": "location",
    "in": "query",
    "description": "SoFL= 26.16,-80.20",
    "required": true,
    "type": "string"
},

那个位置是 (Latitude,Longitude),我用 C# TypeConverter 分割它
...请求看起来像:
http://turoapi.azurewebsites.net/api/Echo?location=26.16,-80.20

That location is (Latitude,Longitude) and I split it with a C# TypeConverter
...and the request looks like:
http://turoapi.azurewebsites.net/api/Echo?location=26.16,-80.20



该 WebApi 的代码在这里:https://github.com/heldersepu/TuroApi

这篇关于Swagger 查询参数模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆