Swagger:是否可以将操作参数设为常量/只读? [英] Swagger: is it possible to make an operation parameter constant / readonly?

查看:43
本文介绍了Swagger:是否可以将操作参数设为常量/只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我对某个参数的描述:

This is the description of a certain parameter I have:

{
    "name": "myParam",
    "description": "My param description",
    "required": true,
    "paramType": "query",
    "type": "string",
    "defaultValue":"myValue"
}

defaultValue 是参数可以拥有的唯一值,那么有没有办法声明它呢?在 swagger-ui 的上下文中看到,我需要参数的文本框是只读的.我正在使用 swagger 1.2.

The defaultValue is the only value the parameter can have, so is there a way to declare this? Seen in the context of the swagger-ui, I need the parameter's textbox to be read-only. I'm using swagger 1.2.

谢谢

推荐答案

正确的声明方式是:

{
    "name": "myParam",
    "description": "My param description",
    "required": true,
    "paramType": "query",
    "type": "string",
    "enum": [ "myValue" ]
}

enum"属性设置可能的值.为它设置一个值后,它就是唯一可以使用的值,并且可以在用户界面中供用户选择.

The "enum" property sets the possible values. Once you set a single value to it, that's the only one that could be used and that would be available in the UI for the user to choose from.

这篇关于Swagger:是否可以将操作参数设为常量/只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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