Layer7 API Management

Expand all | Collapse all

How-to use Validate Against Swagger Document assertion

Jump to Best Answer
  • 1.  How-to use Validate Against Swagger Document assertion

    Posted 04-21-2016 06:18 AM

    Hi everyone,

    I'm trying to use a swagger document to validate requests on my services but I can't validate path of my requests. I have the 11401 error that mean path validation fails according to : Validate Against Swagger Document Assertion - CA API Gateway - 9.0 - CA Technologies Documentation

    I tried using the example of the CA API Gateway documentation and it didn't work.

    I've made a simple swagger document :

    {

        "swagger": "2.0",

        "info": {

            "version": "0.0.0",

            "title": "Simple API"

        },

        "paths": {

            "/test": {

                "get": {

                    "responses": {

                        "200": {

                            "description": "OK"

                        }

                    }

                }

            }

        }

    }

    and a simple policy to test path of my request:

    It still didn't work.

    If someone have tried this assertion and made it worked, i'd like some help on it.

    Thank you.



  • 2.  Re: How-to use Validate Against Swagger Document assertion
    Best Answer

    Posted 04-21-2016 04:54 PM

    Hi BDupont,

     

    Indeed you have a path validation error.

    I'm not familiar with Swagger but I think you are mingling here service uri and request path.

     

    In your example, "testSwaggger" service uri is "/test". If you are sending an http get request to "http(s)://<pathToYourgateway>/test", the request path is empty, throwing an error with your swagger validation assertion.

     

    Try to add a ressource to your service, let's say "movies". Now add this request path to your swagger description (just replace /test with /movies).

    Change the service resolution path resolution logic from your service in order to accept this pattern (in service properties).

     

    Request to http(s)://<pathToYourgateway>/test/movies must now match your new swagger description

     

    Hope this helps !