Giter VIP home page Giter VIP logo

Comments (2)

localstack-bot avatar localstack-bot commented on May 26, 2024

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

from localstack.

bentsku avatar bentsku commented on May 26, 2024

Just a note, we currently support request validators for the request Body, validating the JSON Schema.

def validate_body(self, resource):
# if there's no model to validate the body, use the Empty model
# https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-apigateway.EmptyModel.html
if not (request_models := resource.get("requestModels")):
model_name = EMPTY_MODEL
else:
model_name = request_models.get(APPLICATION_JSON, EMPTY_MODEL)
model_resolver = ModelResolver(
rest_api_container=self.rest_api_container,
model_name=model_name,
)
# try to get the resolved model first
resolved_schema = model_resolver.get_resolved_model()
if not resolved_schema:
LOG.exception(
"An exception occurred while trying to validate the request: could not find the model"
)
return False
try:
# if the body is empty, replace it with an empty JSON body
validate(
instance=json.loads(self.context.data or "{}"),
schema=resolved_schema,
)
return True
except ValidationError as e:
LOG.warning("failed to validate request body %s", e)
return False
except json.JSONDecodeError as e:
LOG.warning("failed to validate request body, request data is not valid JSON %s", e)
return False
# TODO implement parameters and headers
def validate_parameters_and_headers(self, resource):
return True

We are however still missing validating URI, query string, and headers.

from localstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.