compojure-api/schema/swagger 中的非必需参数? [英] Non-required arguments in compojure-api/schema/swagger?
本文介绍了compojure-api/schema/swagger 中的非必需参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我有这样的 API 定义时:
When I have a definition of an API like this:
(POST* "/register" []
:body-params [username :- String,
password :- String,
name :- String]
(ok)))
使名称可选的适当方法是什么?是吗:
what's the appropriate way of making name optional? Is it:
(POST* "/register" []
:body-params [username :- String,
password :- String,
{name :- String nil}]
(ok)))
推荐答案
你知道它使用 letk
管道符号,据我记得语法是正确的,但默认值应该与预期的类型,所以我会说它应该是 ""
而不是 nil
作为 (string? nil)
=> false代码>
As you know it uses letk
plumbing notation and as far as I recall the syntax is correct but the default value should be consistent with the expected type so I'd say it should be ""
rather than nil
as (string? nil)
=> false
(POST* "/register" []
:body-params [username :- String,
password :- String,
{name :- String ""}]
(ok)))
这篇关于compojure-api/schema/swagger 中的非必需参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文