有没有办法将测试文件导入到 redoc x-codeSamples 源字段中?
重做指南指定使用原始文本作为代码示例中的源: https://github.com/ Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md#x-codeSamples 像这样:
lang: JavaScript
source: console.log('Hello World');
但是我想让我的 OpenApi3.0 YAML 成为一个动态文档,因此更愿意直接从测试文件导入代码,例如:
lang: JavaScript
source: #/tests/js_api_test.js
其中 js_api_test.js
的内容只是
console.log('Hello World');
:只要测试通过,导入的代码就可以保证工作 - 保持文档的生命力。
鉴于我已经依赖于从 YAML 文件生成大量样板,因此保持文件的所有方面都保持活力似乎是理想的选择。
The redoc guide specifies using raw text as source in a code sample:
https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md#x-codeSamples
like so:
lang: JavaScript
source: console.log('Hello World');
however I would like to keep my OpenApi3.0 YAML a living document, so would prefer to actually import code directly from test files, ex:
lang: JavaScript
source: #/tests/js_api_test.js
where the contents of js_api_test.js
is just:
console.log('Hello World');
this way the imported code could be guaranteed to work as long as the tests are passing - keeping the document living.
Given I am already relying on generating lots of boilerplate off of the YAML file it seems ideal to keep all aspects of the file living.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到答案:
将在那里导入相对路径文件 test.py
found answer:
will import the relative path file test.py there