Forum Discussion

Emperor's avatar
Emperor
Visitor
2 years ago
Solved

Swagger at runtime

Hi,

I am new to Swagger. So this is a very basic question.

I have defined my APIs using Swagger. The APIs contains request and response objects. I have also uploaded Swagger to my API Gateway.

The question is what happens to my API spec at runtime, i.e., when a new request comes in. Does the API Gateway act as a simple pass through service and it is my responsibility to validate that the request contains correct request body with correct data types? Or is this done by the API Gateway?

  • Emperor Hi

    Your Swagger file is your "application contract" or your "functional specification".
    When you serve the client request, your API Gateway is acting as a API hub where all the API traffic is passing thru.(it checks the access grants as well).
    In addition, it validates the calls and the responses.
    For example, if the client is sending a request to the server with a value that does not fit to the Swagger definition (pattern, enum, nullable etc.) it will raise an error.

    In the same manner, if the server is sending back a response that does not fit to the Swagger definition, it will raise an error.
    In conclusion, it acts as a gatekeeper.

1 Reply

  • chichepo's avatar
    chichepo
    Champion Level 3

    Emperor Hi

    Your Swagger file is your "application contract" or your "functional specification".
    When you serve the client request, your API Gateway is acting as a API hub where all the API traffic is passing thru.(it checks the access grants as well).
    In addition, it validates the calls and the responses.
    For example, if the client is sending a request to the server with a value that does not fit to the Swagger definition (pattern, enum, nullable etc.) it will raise an error.

    In the same manner, if the server is sending back a response that does not fit to the Swagger definition, it will raise an error.
    In conclusion, it acts as a gatekeeper.