【发布时间】:2019-07-08 10:23:55
【问题描述】:
如何使用 Swagger Node.js 注释正确定义以下正则表达式pattern?
* reviews_ratings_description:
* type: string
* minimum: 10
* maximum: 50
* pattern: "^[ a-zA-Z0-9](?!,.*?[^\na-zA-Z0-9!”$%&~^&#<>.?:"'’=@()*\+,\/;\[\\\]\-^_`{|}~]{1}).*?[a-zA-Z0-9!”$%&~^&#<>.?:"'’=@()*\+,\/;\\\\]\-^_`{|}~]$"
运行上面的代码会产生以下错误:
{"error":{},"level":"error","message":"uncaughtException: YAMLException: can not read an implicit mapping pair; a colon is missed at line 42, column 159:\n ... \"'’=@()*\\+,\\/;\\[\\\\\\]\\-^_`{|}~]$'\n
pattern 字符串是否需要以某种方式转义?
【问题讨论】: