admin管理员组文章数量:1122832
I'm wondering if there are extensions, libraries or applications which can help create examples from OpenAPI rulesets used for linting OpenAPI specifications.
I've been googling for "generate examples specification from openapi ruleset", what mainly comes up is the OpenAPI specification itself.
Example ruleset:
extends: spectral:oas
rules:
rule-important-info-fields:
description: Absolutely must have the info information
message: "Missing the {{property}}"
given: "$.info"
severity: error
then:
- field: "title"
function: truthy
- field: "description"
function: truthy
- field: "version"
function: truthy
rule-path-description:
description: Each operation must have a description which cannot be empty.
given: $.paths.[*][get,post,put,delete,options]
severity: error
then:
field: description
function: truthy
rule-camel-case-operation-id:
description: OperationId should be pascalCased.
type: style
given: $.paths.[*][get,post,put,delete,options]
then:
field: operationId
function: casing
functionOptions:
type: pascal
rule-camel-case-parameter-name:
description: Parameter name should be camelCased.
message: "The value '{{value}}' should be camel cased."
type: style
given: $.paths.[*][get,post,put,delete,options].parameters[*]
severity: error
resolved: false
then:
field: name
function: casing
functionOptions:
type: camel
rule-operation-singular-tag:
description: Operations must have at least one tag value.
type: style
given: $.paths.[*][get,post,put,delete,options]
severity: error
then:
field: tags
function: length
functionOptions:
min: 1
rule-path-no-trailing-slash:
description: Paths should not end with `#/`.
type: style
given: "$.paths[*]~"
severity: error
then:
function: pattern
functionOptions:
notMatch: ".+\/$"
rule-path-lower-case-id:
description: Resource identifier in path should be represented as 'xxxId', eg CustomerId.
type: style
given: "$.paths[*]~"
severity: error
then:
function: pattern
functionOptions:
notMatch: "{\\w*id}"
oas3-api-servers: error
Even though tools such as Spectral gives a list of missing fields and values, it would be nice to generate new examples whenever the ruleset changes.
本文标签: lintCreate OpenAPI examples from OpenAPI rulesetStack Overflow
版权声明:本文标题:lint - Create OpenAPI examples from OpenAPI ruleset? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304987a1932429.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论