forked from aws/serverless-application-model
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add validation for API property Model (aws#2340)
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/translator/input/error_api_with_models_of_invalid_type.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Resources: | ||
MyApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: Prod | ||
Models: | ||
- Invalid_value | ||
|
||
MyFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
InlineCode: | | ||
exports.handler = async (event, context, callback) => { | ||
return { | ||
statusCode: 200, | ||
body: 'Success' | ||
} | ||
} | ||
Events: | ||
None: | ||
Type: Api | ||
Properties: | ||
RequestModel: | ||
Model: User | ||
Required: true | ||
RestApiId: | ||
Ref: MyApi | ||
Method: get | ||
Path: /none | ||
|
||
Outputs: | ||
ApiUrl: | ||
Description: "API endpoint URL for Prod environment" | ||
Value: | ||
Fn::Sub: 'https://${MyApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/Prod/' |
3 changes: 3 additions & 0 deletions
3
tests/translator/output/error_api_with_models_of_invalid_type.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 2. Resource with id [MyApi] is invalid. Type of property 'Models' is invalid. Resource with id [MyFunction] is invalid. Event with id [None] is invalid. Unable to set RequestModel [User] on API method [get] for path [/none] because the related API Models defined is of invalid type." | ||
} |