Hi All,

In addition to above, swagger definitions will be provided in json and yaml
formats. Initially it will be done for json. Definitions can be taken from
URLs which has swagger.json and swagger.yaml as query string.

Example:

API Name is SampleAPI

*Json format*
http://localhost:8280:/SampleAPI?swagger.json
http://localhost:8280:/t/abc.com/SampleAPI?swagger.json

*Yaml format*
http://localhost:8280:/SampleAPI?swagger.yaml
http://localhost:8280:/t/abc.com/SampleAPI?swagger.yaml

In order to generate these definition, we are planning to use two new
HttpGetProcessor implementations which can be configured in carbon.xml.

Thanks.

On Tue, Sep 20, 2016 at 4:18 PM, Maheeka Jayasuriya <mahe...@wso2.com>
wrote:

> Hi all,
>
> We are researching on supporting Swagger definitions for REST APIs in ESB.
> This implementation is quite different from what APIM offers. APIM offers a
> Swagger to API configuration generation where as what we need to do here is
> API configuration to Swagger definition generation.
>
> As for the first iteration, I think we can focus on the minimum Swagger
> support where as main focus will be only on the HTTP verb and the
> uri-template or url-mapping.
>
> Following is what I tested to compose a minimal Swagger Definition. I
> started off from the Swagger Pet Store Sample [1] which was reduced to [2]
> and moved on to create [3]. This is IMO the minimum required of a Swagger
> Definition. We can improve from this, but for the time being this would
> suffice the requirement of Integration Cloud.
>
> Please note that I have made the following changes to the original Swagger
> definition of PetStore in order to achieve the final Swagger definition for
> ESB.
>   - Remove descriptions, summary, tags, operationId, schema, basepath,
> definitions and security elements
>   - accept and produce application/json and application/xml as default
> content types for all resources
>   - Include a default response code
>   - Add body as parameter for all POST and PUT operations in addition to
> the uri parameters
>   - All parameters are considered format binary and type String by default
>
> Please note these changes were done based on the level of information we
> have on the API by referring to it's configuration. For example, we do not
> have a way of determining the request format or uri parameter types and
> content-types of the API. This will require further digging and analyzing
> on the configuration.
>
> Find the diff of these changes done to the Swagger definition at [4]
>
> To get the required information from the Rest API configuration we can
> invoke RestApiAdminServices's getApiByName operation which returns the
> following response [5] for an API created that has the PetStore resources.
> We can identify the methods and uri-template and mappings from this
> response.
>
> Please let know your thoughts.
>
> Thanks,
> Maheeka
>
> [1] http://petstore.swagger.io/#/pet
> [2] https://gist.github.com/maheeka/4eaedd2e2e0765959a4166865bf9adf9
> [3] https://gist.github.com/maheeka/ec23751f21d8d7d5abaa4f9130f233f2
> [4] https://www.diffchecker.com/xEu0NSNz
> [5] <soapenv:Envelope xmlns:soapenv="http://schemas.
> xmlsoap.org/soap/envelope/">
>    <soapenv:Body>
>       <ns:getApiByNameResponse xmlns:ns="http://org.apache.axis2/xsd";>
>          <ns:return xsi:type="ax2476:APIData" xmlns:ax2476="
> http://api.rest.carbon.wso2.org/xsd"; xmlns:xsi="http://www.w3.org/
> 2001/XMLSchema-instance">
>             <ax2476:artifactContainerName xsi:nil="true"/>
>             <ax2476:context>/pet</ax2476:context>
>             <ax2476:fileName>PetstoreAPI.xml</ax2476:fileName>
>             <ax2476:host xsi:nil="true"/>
>             <ax2476:isEdited>false</ax2476:isEdited>
>             <ax2476:name>PetstoreAPI</ax2476:name>
>             <ax2476:port>-1</ax2476:port>
>             <ax2476:resources xsi:type="ax2476:ResourceData">
>                <ax2476:contentType xsi:nil="true"/>
>                <ax2476:faultSeqXml xsi:nil="true"/>
>                <ax2476:faultSequenceKey xsi:nil="true"/>
>                <ax2476:inSeqXml xsi:nil="true"/>
>                <ax2476:inSequenceKey xsi:nil="true"/>
>                <ax2476:methods>POST</ax2476:methods>
>                <ax2476:methods>PUT</ax2476:methods>
>                <ax2476:outSeqXml xsi:nil="true"/>
>                <ax2476:outSequenceKey xsi:nil="true"/>
>                <ax2476:protocol>0</ax2476:protocol>
>                <ax2476:uriTemplate xsi:nil="true"/>
>                <ax2476:urlMapping>/</ax2476:urlMapping>
>                <ax2476:userAgent xsi:nil="true"/>
>             </ax2476:resources>
>             <ax2476:resources xsi:type="ax2476:ResourceData">
>                <ax2476:contentType xsi:nil="true"/>
>                <ax2476:faultSeqXml xsi:nil="true"/>
>                <ax2476:faultSequenceKey xsi:nil="true"/>
>                <ax2476:inSeqXml xsi:nil="true"/>
>                <ax2476:inSequenceKey xsi:nil="true"/>
>                <ax2476:methods>POST</ax2476:methods>
>                <ax2476:methods>DELETE</ax2476:methods>
>                <ax2476:methods>GET</ax2476:methods>
>                <ax2476:outSeqXml xsi:nil="true"/>
>                <ax2476:outSequenceKey xsi:nil="true"/>
>                <ax2476:protocol>0</ax2476:protocol>
>                <ax2476:uriTemplate>/{petId}</ax2476:uriTemplate>
>                <ax2476:urlMapping xsi:nil="true"/>
>                <ax2476:userAgent xsi:nil="true"/>
>             </ax2476:resources>
>             <ax2476:statisticsEnable>false</ax2476:statisticsEnable>
>             <ax2476:tracingEnable>false</ax2476:tracingEnable>
>          </ns:return>
>       </ns:getApiByNameResponse>
>    </soapenv:Body>
> </soapenv:Envelope>
>
>
> Thanks,
>
> Maheeka Jayasuriya
> Senior Software Engineer
> Mobile : +94777750661
>



-- 
Jagath Ariyarathne
Technical Lead
WSO2 Inc.  http://wso2.com/
Email: jaga...@wso2.com
Mob  : +94 77 386 7048
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to