简体   繁体   English

如何从SwaggerHub为WSO2 API Manager添加Swagger定义?

[英]How to add a Swagger definition for WSO2 API Manager from SwaggerHub?

In my case, I'm using WSO2 API Manager version 1.7. 就我而言,我正在使用WSO2 API Manager 1.7版。 This version allows loading an externally published Swagger definition and importing it via a URL. 此版本允许加载外部发布的Swagger定义并通过URL导入。

I designed a Swagger definition on SwaggerHub and published on there. 我在SwaggerHub上设计了一个Swagger定义,并在那里发布。 But I couldn't load that definition into API Manager. 但是我无法将该定义加载到API Manager中。

Also, I just copied the Swagger JSON and pasted when editing the API definition after adding an API. 另外,添加API后,在编辑API定义时,我只复制了Swagger JSON并粘贴。 Even though it shows properly saved, I cannot see the exact JSON content. 即使显示正确保存,我也看不到确切的JSON内容。 It has been saved as some text. 它已另存为一些文本。

How can I resolve these issues and add a properly working Swagger definition to WSO2 API Manager 1.7? 如何解决这些问题,并向WSO2 API Manager 1.7中添加正确运行的Swagger定义?

NOTE: It works with 1.10. 注意:它适用于1.10。

What is the swagger version you are using? 您使用的是什么版本? If it is working in AM 1.10 the document probably is written in version 2.0. 如果它在AM 1.10中运行,则该文档可能是在2.0版中编写的。 AM 1.7 use older version of swagger (v1.1). AM 1.7使用旧版本的swagger(v1.1)。 This probably could be the reason for not working in AM 1.7. 这可能是无法在AM 1.7中工作的原因。 If you cannot upgrade to AM 1.10, then you could try creating the swagger doc using the v1.1 notations 如果您无法升级到AM 1.10,则可以尝试使用v1.1表示法创建swagger文档

You should be able to read your API from SwaggerHub directly using this URL structure: 您应该能够使用以下URL结构直接从SwaggerHub读取API:

https://api.swaggerhub.com/apis/{username}/{api-name}/{version}

The accept header can be application/json or application/yaml . accept头可以是application/jsonapplication/yaml If wso2 1.7 is having trouble importing it, there are likely some unsupported features in the wso2 tooling itself. 如果wso2 1.7导入困难,则wso2工具本身可能包含一些不受支持的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM