根据路径从OpenAPI获取操作Id
有没有简单易用的Javascript库能够加载OpenAPI规范并提供基于路径和HTTP方法的操作信息?
示例
const theTool = magicLibrary.loadOpenAPISpec(spec);
const operationInfo = theTool.findOperation({method: 'GET', path: '/resource/1234'});
const operationId = operationInfo.operationId;
请注意,路径可以包含路径参数和查询参数,因此该工具必须真正检查 OpenAPI 规范并提供正确的操作。
Is there any simple to use Javascript library that is capable of loading OpenAPI specification and providing information about operation based on path and HTTP method?
Example
const theTool = magicLibrary.loadOpenAPISpec(spec);
const operationInfo = theTool.findOperation({method: 'GET', path: '/resource/1234'});
const operationId = operationInfo.operationId;
Please note that path can contain path parameter and query parameters so the tool has to really check against OpenAPI specification and provide correct operation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的事情是读取 YAML 并将
/paths
减少为条目,并从条目构建简单的 trie。这大约是 40LoC,达到了目的,而且性能良好、可预测且受控。
Simplest thing was to read YAML and reduces
/paths
as entries and build simple trie from entries.This was around 40LoC and serves purpose and it's performant, predictable and under control.