Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Gateway] Support Request Body Validation #36

Open
ekrengel opened this issue Mar 29, 2019 · 3 comments
Open

[API Gateway] Support Request Body Validation #36

ekrengel opened this issue Mar 29, 2019 · 3 comments
Labels
kind/enhancement Improvements or new features

Comments

@ekrengel
Copy link

ekrengel commented Mar 29, 2019

We are tabling this work. It appears to not add much values since passthrough behavior is not configurable for proxy integrations (like lambdas).

An example of how this may look:

import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

let endpoint = new awsx.apigateway.API("example", {
    routes: [{
        path: "/",
        method: "GET",
        eventHandler: async (event) => {
            return {
                statusCode: 200,
                body: "hello",
            };
        },
        requestBody: {
            modelName: "Example",
            required: true,
            model: {
                type: "object",
                properties: {
                    "key": {
                        type: "string",
                    },
                },
                required: ["key"],
            },
        },
    }],
})

Note that if the requested Content-Type header does not match a model the request will be passed through to your backend. AWS Gateway does not provide the option to modify passthrough behaviors for proxy integrations. For the above example, request validation only works validates the body for requests with "Content-Type: application/json". If the request had a header equal to "Content-Type: application/xml", then API Gateway passes the entire request through to your backend.

@ryanswrt
Copy link

ryanswrt commented Jun 5, 2020

One possible value in having body validation is for generation of the swagger specification - currently it seems like you'd have to do it manually and have no way to ensure that it is kept in sync with the implementation.

@leezen leezen added the kind/enhancement Improvements or new features label Jun 6, 2020
@danielrbradley danielrbradley transferred this issue from pulumi/pulumi-awsx May 19, 2022
@sebaaaz
Copy link

sebaaaz commented Jun 27, 2024

Hello! Any updates of this issue? Is there a way to perform body validation without using the Swagger specification?

We could achieve this by creating the integration separately with pulumi_aws.apigateway.Integration. However, it would be great if the module supported this feature.

@thetoxicavenger
Copy link

thetoxicavenger commented Aug 1, 2024

no judgment, just curious as to why this hasn't been implemented yet? is there a technical challenge here?

Note that if the requested Content-Type header does not match a model the request will be passed through to your backend. AWS Gateway does not provide the option to modify passthrough behaviors for proxy integrations. For the above example, request validation only works validates the body for requests with "Content-Type: application/json". If the request had a header equal to "Content-Type: application/xml", then API Gateway passes the entire request through to your backend.

I don't think that negates the usefulness of this feature, though, right? Sending the wrong content type header feels like an edge case, and you can configure your integration to just send 500 if the content type is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

5 participants