How to hide field base on method PUT or POST or advance condition in spring controller by springdoc-openapi - springdoc

I can't find the way to hide field base on method in springdoc-api.
Example:
For POST method, i want to hide status field in DTO.
For PUT method, i want to show status field in DTO.
How can i config it by springdoc-openapi or anyway i can hidden field base on the condition.

Related

In Spring boot, want to display a field from entity class in output but input is not required

in Spring boot, I have an entity called Event. All the fields from the entity needs to come from user. I want that this entity should contain a field called approval status. This field doesn't need input from user but during display of that entity need that field populated from some source(from approval table) and displayed along with other fields of entity. Is there a way, I can include this field in Event class itself and specify no input or the only way is to create a wrapper class wrapping Event and approval status field?
Thanks,
#Transient is the exact thing which fulfill your use case.
Make field transient in your entity class and then set it in controller from whatever source you want to, and display it in page.
See https://stackoverflow.com/a/42753469/6572971

Wanting to display a method return using HTML 5 data attribute

So I have a dynamic table in angular where im passing data in, then creating the table. I want to add some CSS in order to check the values then add some styling onto it. So if the value is a minus number, then display the data in red
I have used attribute data to check the actual data, which works fine until i call to typescript method to generate the data instead of hardcoding the data in, and this is where is goes wrong. So I want to call this method to get the data instead, and it just displays the method name instead of the method return
You can use the attribute binding of data instead of the interpolation if the data returned by the method is not a string - more details here
[attr.data]="getData(header, body)"

Drupal 8 - JSON API get with parameters

I can get the list of records I have of a custom content by creating a new "view" and setting the response returned in a JSON format
Now I would like to send a get request, with 1 or more parameters, and only return a subset of records whose fields match with my parameters
ex : www.exmample.com/rest/view/customcontent?city=paris
How could I do that ?
You can create a filter (add filter criteria) in the view. Make it exposed and change the Filter identifier field according what you want to have in the URL.

Passing Parameters from View to Action in MVC

I am currently trying to take a value from a drop down list, store it into a variable, and pass it into a controller's action result. When I run my code, the Index is supposed to store the value of the selected item in the dropdown box in the variable SelectedDistrict, then then go to the Query action. Query will take a variable of DistrictViewModel as a parameter and then use var school = getQuery(variable.SelectedDistrict) to go into the function I have. In the function however, it's saying that the variable sd is null whenever i debug. Maybe the value from the drop down box is not storing properly? In the end, I want to display in a table all of the schools in my school table that come from the selected district in the drop down. The table is not being populated because of the null value. Here is my code for more clarity.
District View Model:
School View Model:
Controller w/ getQuery function:
Index View:
Query View:
The table when I run my code:
The problem is that your controller method for Query is expecting some data to be passed in the form of an object, but you aren't passing anything to it. If it's a GET request (and it appears to be because you just set location.href on click), the values would need to be in the query string. Alternatively you can make your form POST to that controller action instead.
You'll need <form> tags. You can GET or POST to your controller method, it won't matter (model binding works either way). It depends on whether you want people to be able to deep-link directly to the search results or not.
<form action="#Url.Action("Query", "District") method="get">
#Html.DropDownListFor(m => m.SelectedDistrict, Model.Districts)
<button type="submit" value="Submit"/>
</form>
That pretty much should do it, or at least get you on the right path.

Admin - Add new post - hook to display some custom input fields

i have a custom post type
this post type needs some fields to be inserted into a custom MySQL table (wp_my_custom_table) where i store some relations IDs with other products and a number to sort them
i don't know how to put these input fields them after the textarea. I know how to insert them at "save_post" action hook.
these are not registered as "custom fields", are just a few input fields needed for each post type like this
The tag doesn't work, so i put the code that i have tried as image:
I have found, there is a hook "edit_form_after_editor".