如何在Swagger YAML架构中为响应元素名称添加正则表达式模式?

问题描述 投票:0回答:1

我具有以下YAML架构:

Info:
      type: object
      properties:
        "qwdqwqwwdqwdwq134241HHOIHD2134":
          type: object
          properties:
            qwdqwqwwdqwdwq134241HHOIHD2134.a.span:
              type: object
              properties:
                10.142.0.89:54851-54.235.235.95:54336:
                  type: object
                  properties:
                    state:
                      type: string
                      example: IDLE

名称:10.142.0.89:54851-54.235.235.95:54336可以是示例正则表达式之后的任何字符串,例如:10[^_]++

我将如何定义它,使其仍然显示10.142.0.89:54851-54.235.235.95:54336作为示例值,但还要提到它可以是正则表达式10[^_]++之后的任何字符串?

yaml swagger swagger-ui jsonschema openapi
1个回答
0
投票

因为^.*$匹配任何内容,所以只能使用关键字additionalProperties

        type: object
        additionalProperties:
          type: object
          properties:
            qwdqwqwwdqwdwq134241HHOIHD2134.a.span:
              type: object
              properties:
                10.142.0.89:54851-54.235.235.95:54336:
                  type: object
                  properties:
                    state:
                      type: string
                      example: IDLE
© www.soinside.com 2019 - 2024. All rights reserved.