Layer7 API Management

Expand all | Collapse all

Expose swagger from a CA API-GW performing SOAP to REST conversion

Jump to Best Answer
  • 1.  Expose swagger from a CA API-GW performing SOAP to REST conversion

    Posted 06-19-2017 06:39 AM

    Hi,

     

    How can I expose a swagger document/page from the CA API-GW generated REST-api.

     

    Previously, before adding CA, the APIs developed have been published with a swagger documentation. 

     

    We now use CA API-GW to transform SOA to REST, and assert on oauth tokens using an external identity provider.

     

    Best Regards David Karlsson.



  • 2.  Re: Expose swagger from a CA API-GW performing SOAP to REST conversion
    Best Answer

    Posted 06-26-2017 01:45 AM

    Hello,

    Not sure if I understand your question correctly, if you want to publish a json (swagger)file on gateway,

    for example, if you have an api /test/testfile , and you want a /test/testfile.json, you can publish a new service /test/testfile.json on gateway, in the policy, just add Return Template Response to Requestor assertion, set content-type as text/json; charset=UTF-8, and put the swagger file content to response body.

     

    Regards,

    Mark



  • 3.  Re: Expose swagger from a CA API-GW performing SOAP to REST conversion

    Posted 06-26-2017 03:28 AM

    The problem is that we do not have anything to publish:

     

    When building Java REST-layers, and Node JS REST layers, the swagger doc usually is generated automatically from jsdocs or java annotations.

     

    However now we are building the REST layer entirely in the CA GW, it is okay if we only want limited logic in the layer... But one thing we are missing out on is the Swagger generation.


    I later found that it has been mentioned before that CA lacks this support . However it should be quite easy to develop, for instance something similar to what: swagger-jsdoc does for nodejs.

     

    swagger-jsdoc/GETTING-STARTED.md at master · Surnet/swagger-jsdoc · GitHub 

     

    Where the extremely trivial syntax below:

    /** * @swagger * /login: *   post: *     description: Login to the application *     produces: *       - application/json *     parameters: *       - name: username *         description: Username to use for login. *         in: formData *         required: true *         type: string *       - name: password *         description: User's password. *         in: formData *         required: true *         type: string *     responses: *       200: *         description: login */app.post('/login', function(req, res) {   res.json(req.body); });

    creates the entire swagger file for the nodejs login endpoint.

     

    I sincerely hope this is something you would like to investigate further asap, for everyones good feature request...

     

    Best Regards David Karlsson.



  • 4.  Re: Expose swagger from a CA API-GW performing SOAP to REST conversion

    Posted 06-26-2017 09:49 PM

    I see.

    Yes, you're right, gateway cannot generate the swagger document automatically. You can raise an idea ticket for this.

     

    Thanks,

    Mark