Comments (2)
Hi @juanitosvq, thanks for trying to fix this in Moto! That is quite odd behaviour from AWS - I would expect them to return a 400
here instead.
The dispatch-method uses the URL's supplied by botocore
, and botocore seems to also always expect the api_id
to have some value.
Instead of fighting the url-matcher, and challenging/changing all the assumptions that the dispatch
-method makes, I would suggest adding a custom method to handle this use-case. It is an outlier - I don't think I've seen anything else like this from AWS - so I'm not opposed to having a custom handler to solve this.
diff --git a/moto/apigatewayv2/responses.py b/moto/apigatewayv2/responses.py
index 18d6b1b83..553b1b8e7 100644
--- a/moto/apigatewayv2/responses.py
+++ b/moto/apigatewayv2/responses.py
@@ -20,6 +20,9 @@ class ApiGatewayV2Response(BaseResponse):
"""Return backend instance specific for this region."""
return apigatewayv2_backends[self.current_account][self.region]
+ def get_api_without_id(self, *args):
+ return 200, {}, "{}"
+
def create_api(self) -> TYPE_RESPONSE:
params = json.loads(self.body)
diff --git a/moto/apigatewayv2/urls.py b/moto/apigatewayv2/urls.py
index 72f4922d6..013550a8e 100644
--- a/moto/apigatewayv2/urls.py
+++ b/moto/apigatewayv2/urls.py
@@ -9,6 +9,7 @@ url_bases = [
url_paths = {
"{0}/v2/apis$": ApiGatewayV2Response.dispatch,
+ "{0}/v2/apis/$": ApiGatewayV2Response.get_api_without_id,
"{0}/v2/apis/(?P<api_id>[^/]+)$": ApiGatewayV2Response.dispatch,
"{0}/v2/apis/(?P<api_id>[^/]+)/authorizers$": ApiGatewayV2Response.dispatch,
"{0}/v2/apis/(?P<api_id>[^/]+)/authorizers/(?P<authorizer_id>[^/]+)$": ApiGatewayV2Response.dispatch,
If you could just add a small comment inside the new method to explain this usecases this serves, that would minimize future head scratching. 🙂
Note that I haven't linted this yet, so make sure to run make lint
at the end to make sure our CI is happy - see https://docs.getmoto.org/en/latest/docs/contributing/installation.html#installing-moto-locally
from moto.
Thanks for the feedback, @bblommers
PR opened: #7978
from moto.
Related Issues (20)
- EC2 instance with predefined IP and SubnetId: network interface stays around after instance termination HOT 1
- Incorrect behavior of SageMaker Client Search Method HOT 1
- What’s the master branch‘s actual current package version? HOT 1
- Large size on disk when installing for just one service HOT 2
- The security token included in the request is invalid for glue HOT 1
- ec2.describe_security_group_rules bad output response for IPv4, IPv6, Prefix Lists, Security Groups targets and overlapping port/protocols HOT 1
- implementation_coverage.py script misses covered API calls HOT 1
- Cryptographic API Misuse Vulnerability HOT 1
- Directory Service: DescribeDirectories expects LaunchTime to be a JSON Number, got string instead HOT 2
- No ValidationException raised when calling DDB UpdateItem operation with an empty ExpressionAttributeValues HOT 1
- Sagemaker runtime: InvokeEndpointAsync does not provide FailureLocation parameter HOT 2
- Organizations `create_account()` should create an IAM role in the new "account" HOT 2
- Support for QLDB
- The filter 'kms-key-id' for DescribeSnapshots has not been implemented in Moto yet HOT 1
- Autoscaling groups do not pass launch template to EC2 instances. HOT 3
- update_autoscaling_group returns KeyError instead of ValidationError when ASG name is not found HOT 2
- rds restore_db_instance_to_point_in_time has KeyError bug if run twice HOT 1
- DyanmoDB: empty update expression in `update_item` raises the wrong exception
- Bug in RDS modify_db_instance with CloudwatchLogsExportConfiguration HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moto.