我正在尝试使用dhall键入openapi specification。 按照Security Requirement Object的描述(打开的api对象具有一个数组),我编写以下代码:
let SecurityRequirement =
{
mapKey: Text
, mapValue: List Text
}
in
let req1 : SecurityRequirement =
{ mapKey = "AuthorizationHeader"
, mapValue = ([] : List Text)
}
let req2 : SecurityRequirement =
{ mapKey = "Foo"
, mapValue = ([] : List Text)
}
let requirements : List SecurityRequirement =
[ req1, req2 ]
in requirements
有了这段代码,我得到了
{"Foo":[],"AuthorizationHeader":[]}
在我尝试拥有
[{"Foo":[]},{"AuthorizationHeader":[]}]
。
我如何实现我的目标?
答案 0 :(得分:0)
如果您将SecurityRequirement
的类型更改为List { mapKey : Text, mapValue : List Text }
,则它会按照您的要求进行操作:
let SecurityRequirement = List { mapKey : Text, mapValue : List Text }
let req1
: SecurityRequirement
= [ { mapKey = "AuthorizationHeader", mapValue = [] : List Text } ]
let req2
: SecurityRequirement
= [ { mapKey = "Foo", mapValue = [] : List Text } ]
let requirements : List SecurityRequirement = [ req1, req2 ]
in requirements
$ dhall-to-json <<< './example.dhall'
[{"AuthorizationHeader":[]},{"Foo":[]}]