RAML 1.0,Map类型复杂的正则表达式 [英] RAML 1.0, Map types complex regular expression
本文介绍了RAML 1.0,Map类型复杂的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的api中,我有一个包含uuid->Drive
映射的类型.我使用了Map类型[1]来定义它:
In my api, I have a type who contains a map of uuid->Drive
. I have used a Map type[1] to define that :
type: object
properties:
drives:
required: false
type: object
properties:
[(a-zA-Z0-9-)*] :
type: Drive
这项工作,但我想在模式上更精确.但是我无法使其正常工作.
That work but I would like to be more precise on the pattern. However I can't manage to have it working.
-
["(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}"]:
似乎没有用作正则表达式. -
[(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}]:
说流收集条目之间的逗号缺失
["(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}"]:
Don't seems to be used as regular expression.[(a-zA-Z0-9){8}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){4}-(a-zA-Z0-9){12}]:
Say Missed comma between flow collection entries
如何在具有RAML 1.0的Map类型中使用复杂的表达式?
How can I use a complex expession in a Map type with RAML 1.0 ?
(我正在使用API Workbench)
(I'm using API Workbench)
[1] http://docs.raml. org/specs/1.0/#raml-10-spec-map-types
推荐答案
您需要使用以/^开头并以$/
You need to use a RegEx string that starts with /^ and ends with $/
#%RAML 1.0
title: My API With Types
types:
Person:
properties:
name:
required: true
type: string
age:
required: false
type: number
/^note\d+$/: # restrict any properties whose keys start with "note"
# followed by a string of one or more digits
type: string
https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#additional-properties
这篇关于RAML 1.0,Map类型复杂的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文