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

RequestValidator shouldn't require (or even expect) a restApi property. #6193

Closed
richardhboyd opened this issue Feb 10, 2020 · 1 comment · Fixed by #6780
Closed

RequestValidator shouldn't require (or even expect) a restApi property. #6193

richardhboyd opened this issue Feb 10, 2020 · 1 comment · Fixed by #6780
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on.

Comments

@richardhboyd
Copy link
Contributor

Specifying a requestModel in the MethodOptions of an AddMethod() operations should create the RequestValidator for me. Currently I have to also manually construct a RequestValidator.

Currently I have to build something like this:

    languageResource.addMethod("POST", new apigw.Integration({
      type: apigw.IntegrationType.AWS,
      uri: `arn:aws:apigateway:${cdk.Aws.REGION}:events:path//`,
      integrationHttpMethod: "POST",
      options: options,
    }),
    {
      methodResponses: [{
          statusCode: "200"
        }],
      requestModels: {"application/json": model.getModel(this, myRestAPI) },
      requestValidator: new apigw.RequestValidator(this, "myValidator", {
        restApi: myRestAPI,
        validateRequestBody: true
      })
    })

The validator is being added to a resource, which is inherently attached to a RestAPI. Asking users to specify it again adds no value and we should just add it for them.

@richardhboyd richardhboyd added the needs-triage This issue or PR still needs to be triaged. label Feb 10, 2020
@SomayaB SomayaB added feature-request A feature should be added or improved. @aws-cdk/aws-apigateway Related to Amazon API Gateway labels Feb 10, 2020
@nija-at nija-at added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md and removed needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2020
@nija-at
Copy link
Contributor

nija-at commented Feb 13, 2020

The change will involve deprecating this property in favour of a new property (like reqValidator) of the type RequestValidatorOptions

nirvana124 pushed a commit to nirvana124/aws-cdk that referenced this issue Mar 18, 2020
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Mar 19, 2020
@mergify mergify bot closed this as completed in #6780 Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants