AWS API Gateway- No options for models in Method Response - httpresponse

https://imgur.com/a/sN5aPg0
Under models, there's no options to choose from for Application/Json content type. I want an empty model for my method response. How do I create this model?

You can create a model with empty schema {}. Then you can select that model in method response.

Related

Can Laravel model validate the field data types(int,float,..etc) while inserting data?

My problem is that I'm using noSql for my database and Laravel for the backend.
I know that we can validate the data types in the request but this validates only the incoming request after that we might calculate or re-arrange the data type of a field and insert it. I want to prevent this insertion by checking the data types. Is there a way to implement this validation in model like fillable [] or casts [].
You could setup an Observer on that model and in the Observer's 'updating' method you could perform any type formatting or cleanup required.
Or if it's a real edge case you could call the Validator facade to define the keys/rules to check for and then pass your changed object to it? If Validator->fails() you could loop through Validator->errors() and apply corrections as needed.

defining routes with parameters in laravel

in Laravel i want to do a page with a search box and a form (the route could be /products)
I want to retrieve information using search box typing id from a db and populate the form.
I request datas with the route for example /products/{id}
But in the controller i use the same function products($Request request) with if the id exists do something if no do other things, or there are two different functions?
Thx
Please go through the Laravel Resource Controllers.
To show list of products i.e. /products, create a index() method. To show a specific product i.e. /product/{id}, create show() method.
Probably is better use the same function, if id exist, return the page with the values filling the form, if not returns the same page but with a message showing that product doesn't exist

Access tables names in middleware in a single transaction

Let's say CRUD operations are performed on three tables in a single controller method.
Is it possible for me to get all the tables names on which CRUD operations are performed in the middleware.
As of now, when I submit a form I can only access those inputs from the request in the middleware, but when I insert three records into three different tables in a single controller action am not able to access the table names in the middleware.
Any help is much appreciated.
I don't think that it is possible to get table name automatically. You will have to right custom logic in middleware for that controller action. Because the response object we get in middleware after the execution of controller method is html, json, etc response which is to be sent to client.

How to Pass Two Different Json objects and Header bean object to spring mvc controller.?

I have been working with Header and Line Records in Spring MVC.I have header Employee object and Two different Employee Address,Employee Salary details of Json Objects.I need to send all the three objects.
Object 1 - Employee Header Bean object
Object 2- Employee Address Json Object
Object 3- Employee Salary Json Object.
My Question is How to send these objects from Ajax call of jsp and How to receive these objects in the spring mvc controller?
Please help me on this.

MVC: Is it considered bad form to give a DTO a reference to the data access layer?

Is it considered bad form to give a DTO a reference to the data access layer?
Or should you always pass a DTO between the data access layer and the application layer?
EDIT: For example, imagine the following:
I keep a product types list in my database.
I'd like to render this list in a drop-down box in a partial view.
This partial view is strongly-typed to a DTO.
Question:
Should I retrieve my product types list first, and then pass it to the DTO via its constructor?
Or is it acceptable to pass a repository reference to the DTO, and then expect it to retrieve this list from the data access layer?
A DTO should never have a reference to the data access layer.
Rather a DTo is a simple transfer object that contains only data and is used to pass information between layers.
A DTO is for passing data from the business layer to your presentation layer. This way you can bind the DTO to your combobox.
The DTO should be populated inside the business layer (middle tier), like when calling a service. The service will call the DAL by for example by DAO's.

Resources