我有一个表,其中有一个字段(字符串),上面有一个完整的Swagger文本。
字段示例
swagger: '2.0'
info:
title: "Values"
version: 2.4.0
description: "Lorem iosum."
license:
name: Copyright
url: 'https://lorem.com/'
x-catalogation:
ba: "Execution"
bd: "Loans"
bdd: "Account"
schemes:
- "https"
basePath: "/v2/values"
consumes:
- "application/json"
produces:
- "application/json"
securityDefinitions:
JWTProfile:
type: "oauth"
description: 'OGT'
flow: "implicit"
scopes:
valueid.read: "lorem"
valuelist.read: "lorem"
valuetran.read: "lorem"
value: "lorem"
vlimit: "lorem"
valuestat.read: "lorem"
authorizationUrl: "$(authorization-url)"
x-tokenIntrospect:
url: "$(sca-security-url)"
paths:...
查询的期望结果必须是valueid.read valuelist.read valuetran.read value vlimit valuestat.read
我尝试了这个查询select unnest (regexp_matches(api_spec, E'\"([a-z]+\\.[a-z]+)\"', 'g')) as scopes from apis
但我只检索这个范围valueid.read valuelist.read valuetran.read valuestat.read
我在一个角落里,有人能帮我吗?
1条答案
按热度按时间2lpgd9681#
**免责声明:**我建议将此答案视为纯粹的练习:如果你需要解析YAML,最好使用一些支持YAML格式解析的库的编程语言。
假设
scope
的子元素的缩进总是相同的,并且它们都没有任何子元素,你可以用下面的查询提取作用域子元素的名称:示例的预期输出:
| 儿童|
| --------------|
| valueid.read |
| valuelist.read |
| valuetran.read |
| 价值|
| vlimit|
| valuestat.read |
演示here