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

Internal transform failure on path parameters #913

Merged
merged 29 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f50e01
Added fix for Internal transform failure on bad Condition syntax
Apr 28, 2019
75e3f85
removed un unsed exception import and lint
Apr 28, 2019
f761208
added test file in end to end terst
Apr 28, 2019
8ff0993
Added test file in error check condition
Apr 29, 2019
a954bf5
updated test file with different type
Apr 29, 2019
b2a2b13
Added condition in template
May 1, 2019
0218b45
Added fix for Internal transform failure on bad Condition syntax
Apr 28, 2019
d9e2c4c
removed un unsed exception import and lint
Apr 28, 2019
a0c3935
added test file in end to end terst
Apr 28, 2019
1168702
Added test file in error check condition
Apr 29, 2019
b7aeccd
updated test file with different type
Apr 29, 2019
67507b4
Added condition in template
May 1, 2019
8de24bf
Updated conditionvalidation in resouce file also updated error respon…
May 3, 2019
80e31f4
handle unicode string compare for condition
May 3, 2019
a987866
Added check for python version
May 3, 2019
b772caa
Added check for condition name
May 3, 2019
0db06e8
updated condition check
May 3, 2019
c334da0
Merge branch 'master' of https://github.com/jadhavmanoj/serverless-ap…
May 3, 2019
9e7fd28
Merge branch 'master' into develop
May 3, 2019
1d435ba
use string_types from six for type checking
keetonian May 3, 2019
fb5631e
use is_str helper function for str type checking
keetonian May 3, 2019
17a3014
Merge branch 'develop' of https://github.com/jadhavmanoj/serverless-a…
May 5, 2019
733bdd7
Added fix for Internal transform failure on path parameters
May 6, 2019
0c0e289
address feedback
keetonian May 7, 2019
2146897
address feedback
keetonian May 7, 2019
3231816
Merge branch 'develop' of https://github.com/jadhavmanoj/serverless-a…
May 9, 2019
06d9619
Merge branch 'develop' of https://github.com/jadhavmanoj/serverless-a…
May 9, 2019
b20ed69
Merge branch 'swagger-bug' into develop
May 9, 2019
4678bf9
Merge remote-tracking branch 'upstream/develop' into develop
May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions samtranslator/swagger/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ def set_path_default_authorizer(self, path, default_authorizer, authorizers):
authorizers param.
:param list authorizers: List of Authorizer configurations defined on the related Api.
"""

for method_name, method in self.get_path(path).items():
# Excluding paramters section
if method_name == "parameters":
continue
self.set_method_authorizer(path, method_name, default_authorizer, authorizers,
default_authorizer=default_authorizer, is_default=True)

Expand Down
64 changes: 64 additions & 0 deletions tests/translator/input/global_handle_path_level_parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Globals:
Api:
Name: "some api"
CacheClusterEnabled: True
CacheClusterSize: "1.6"
Auth:
DefaultAuthorizer: MyCognitoAuth
Authorizers:
MyCognitoAuth:
UserPoolArn: !GetAtt MyUserPool.Arn
Variables:
SomeVar: Value

Resources:
ImplicitApiFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/member_portal.zip
Handler: index.gethtml
Runtime: nodejs4.3
Events:
GetHtml:
Type: Api
Properties:
Path: /
Method: get

ExplicitApi:
Type: AWS::Serverless::Api
Properties:
StageName: SomeStage
DefinitionBody:
swagger: 2.0
info:
version: '1.0'
title: !Ref AWS::StackName
paths:
"/":
parameters:
- name: domain
in: path
description: Application domain
type: string
required: true
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations
responses: {}

MyUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: UserPoolName
Policies:
PasswordPolicy:
MinimumLength: 8
UsernameAttributes:
- email
Schema:
- AttributeDataType: String
Name: email
Required: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
{
"Resources": {
"ImplicitApiFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "index.gethtml",
"Code": {
"S3Bucket": "sam-demo-bucket",
"S3Key": "member_portal.zip"
},
"Role": {
"Fn::GetAtt": [
"ImplicitApiFunctionRole",
"Arn"
]
},
"Runtime": "nodejs4.3",
"Tags": [
{
"Value": "SAM",
"Key": "lambda:createdBy"
}
]
}
},
"ImplicitApiFunctionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"ManagedPolicyArns": [
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
],
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
]
}
}
},
"ImplicitApiFunctionGetHtmlPermissionTest": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"Principal": "apigateway.amazonaws.com",
"FunctionName": {
"Ref": "ImplicitApiFunction"
},
"SourceArn": {
"Fn::Sub": [
"arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/",
{
"__Stage__": "*",
"__ApiId__": {
"Ref": "ServerlessRestApi"
}
}
]
}
}
},
"ExplicitApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"paths": {
"/": {
"parameters": [
{
"required": true,
"type": "string",
"description": "Application domain",
"name": "domain",
"in": "path"
}
],
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations"
}
},
"security": [
{
"MyCognitoAuth": []
}
],
"responses": {}
}
}
},
"swagger": 2.0,
"securityDefinitions": {
"MyCognitoAuth": {
"in": "header",
"type": "apiKey",
"name": "Authorization",
"x-amazon-apigateway-authorizer": {
"providerARNs": [
{
"Fn::GetAtt": [
"MyUserPool",
"Arn"
]
}
],
"type": "cognito_user_pools"
},
"x-amazon-apigateway-authtype": "cognito_user_pools"
}
}
},
"EndpointConfiguration": {
"Types": [
"REGIONAL"
]
},
"Name": "some api",
"Parameters": {
"endpointConfigurationTypes": "REGIONAL"
}
}
},
"ServerlessRestApiProdStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"StageName": "Prod",
"CacheClusterSize": "1.6",
"Variables": {
"SomeVar": "Value"
},
"CacheClusterEnabled": true,
"DeploymentId": {
"Ref": "ServerlessRestApiDeploymente1212668e0"
}
}
},
"ServerlessRestApiDeploymente1212668e0": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
"Ref": "ServerlessRestApi"
},
"Description": "RestApi deployment id: e1212668e096994ab32167666f5a877bd6ac5fad",
"StageName": "Stage"
}
},
"ExplicitApiSomeStageStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"RestApiId": {
"Ref": "ExplicitApi"
},
"StageName": "SomeStage",
"CacheClusterSize": "1.6",
"Variables": {
"SomeVar": "Value"
},
"CacheClusterEnabled": true,
"DeploymentId": {
"Ref": "ExplicitApiDeployment9a254aa466"
}
}
},
"ImplicitApiFunctionGetHtmlPermissionProd": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"Principal": "apigateway.amazonaws.com",
"FunctionName": {
"Ref": "ImplicitApiFunction"
},
"SourceArn": {
"Fn::Sub": [
"arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/",
{
"__Stage__": "Prod",
"__ApiId__": {
"Ref": "ServerlessRestApi"
}
}
]
}
}
},
"MyUserPool": {
"Type": "AWS::Cognito::UserPool",
"Properties": {
"UsernameAttributes": [
"email"
],
"UserPoolName": "UserPoolName",
"Policies": {
"PasswordPolicy": {
"MinimumLength": 8
}
},
"Schema": [
{
"AttributeDataType": "String",
"Required": false,
"Name": "email"
}
]
}
},
"ExplicitApiDeployment9a254aa466": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
"Ref": "ExplicitApi"
},
"Description": "RestApi deployment id: 9a254aa466c6f818951dfb6e45fde65489beb153",
"StageName": "Stage"
}
},
"ServerlessRestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Body": {
"info": {
"version": "1.0",
"title": {
"Ref": "AWS::StackName"
}
},
"paths": {
"/": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations"
}
},
"security": [
{
"MyCognitoAuth": []
}
],
"responses": {}
}
}
},
"swagger": "2.0",
"securityDefinitions": {
"MyCognitoAuth": {
"in": "header",
"type": "apiKey",
"name": "Authorization",
"x-amazon-apigateway-authorizer": {
"providerARNs": [
{
"Fn::GetAtt": [
"MyUserPool",
"Arn"
]
}
],
"type": "cognito_user_pools"
},
"x-amazon-apigateway-authtype": "cognito_user_pools"
}
}
},
"EndpointConfiguration": {
"Types": [
"REGIONAL"
]
},
"Name": "some api",
"Parameters": {
"endpointConfigurationTypes": "REGIONAL"
}
}
}
}
}
Loading