SwaggerUI 3.x: How can I set parameter value programmatically? - swagger-ui

I'm using SwaggerUI 3.21.0 and would like to set a query parameter value programmatically. When you press the button, the calculated value is set as the parameter. The parameter itself is defined in the openapi.yaml and a textbox is created by SwaggerUI. First I tried $(element).val(value) with jQuery, and the value appeared in the textbox, however it didn't affect the url SwaggerUI requests. Next I noticed that SwaggerUI uses React under the hood, and tried FindReact and setState from the question below. However, this also didn't affect the url. It seems like that SwaggerUI keeps the values somewhere internally. Does anyone have any idea?
React - getting a component from a DOM element for debugging

The missing was to trigger event for React. This answer worked charmly!
https://stackoverflow.com/a/46012210/5209556

Related

Migrate autocomplete field to dynamic dropdown

I’m using Oberon forms version 2019.2 CE.
I want to migrate autocomplete field to dynamic dropdown. As resource (Resource URL) I'm using address: <my_service_address>/name={$fr-search-value}&param2={../c_field_name}
c_field_name is other dynamic dropdown.
When I’m using autocomplete everything is fine (correct response from service), but when I switch to dynamic dropdown the response is incorrect (empty response). It looks like {../c_field_name} is empty value.
When I pass some test value to my service (instead of {../c_field_name}), for example:
<my_service_address>/name={$fr-search-value}&param2=1
everything work fine, so my service working well.
I tried to use $c_field_name instead of {../c_field_name}, but it is not worked.
Do you have any suggestions?
Instead of ../c_field_name, use xxf:instance('fr-form-instance')//c_field_name.
Also see the form attached to this message, which uses this technique to create chained dropdowns, where each dropdown passes to the service the value selected by the user in the previous dropdown. And ideally, you should be able to just write $c_field_name, which is covered by request for enhancement #309.

How to reset the field value on a custom form field?

I have a custom field in Jira and I want to set the value on the field to match the current user.
This seems as though it should be fairly easy, but it has stumped me. I have trawled for information and have been led to using post functions.
Post functions don't seem to actually pre-set the value of fields on the create issue screen unfortunately? I am able to set a value which appears on the issue once it is created using a post function but I cant seem to find a way to set the value on the form itself.
Is this possible?
There is Default Values for 'Create Issue' screen plugin which seems to be doing exactly what you want.

Loading select options after setting value

My program flow requires that I first set the value of a select option in the Viewmodel and then I load the available options into the Viewmodel. This causes problems, typically the first available option will be seen in the selection list after this, while the selected option value stays at the specified value.
I was hoping that setting the new "valueAllowUnset" would help, but instead my page becomes unresponsive when using it.
Therefore I currently set the original value again after loading the options. Strangely, this only works when I set the value, set a different value and then set the value again, e.g.
self.data()[field](orgValue);
self.data()[field]({});
self.data()[field](orgValue);
(I store values for multiple selection lists in the self.data observable and access them with the property index "field".)
I tried to strip this down to a simple JSFiddle (http://jsfiddle.net/timvdh/HN6DE/), but the behavior does not show there, although the example pretty much resembles my actual application. However, I am using about 30 select lists there.
So I was hoping, that someone can make an educated guess about what goes wrong in my application, I am hoping that the fact that I have to set the original value three times maybe gives a clue.
EDIT: This fiddle demonstrates, that setting the selected option before and after filling the options list does work with "valueAllowUnset": http://jsfiddle.net/timvdh/HT5Tp/
I am using JQuery Mobile with knockout.js and that caused the problem (sorry I did not even think about JQM being the problem in the first place). I am now setting the option before filling the list and after filling the list I call
$("#selectmenuID").selectmenu("refresh");
to display the option.
The hanging browser was not caused by knockout, there are additional subscriptions to the selectmenus in my app. "valueAllowUnset" changed the behavior of the selectmenus and triggered loops caused by problems in my code.

Zend 2 - Default InArray Validator of Select Element gets lost

I have an issue when adding a filter to my select elements in Zend 2.2. When creating a select element, a default validator is added to this element:
This element adds an InArray validator to its input filter specification in order to validate on the server if the selected value belongs to the values.
This works fine until I add a custom filter to that element:
$filter = new Input('element_name');
$filter->setRequired(true);
$this->add($filter);
This Zend\InputFilter\Input is added to a Zend\InputFilter\InputFilter which is later added to my form. From now on the default validator is lost.
How can I add a filter to form elements without losing their default validators?
Am I missing something? I don't expect this as the default behaviour, because everyone is desperately asking how to deactivate it. There's even an attribute to deactivate it ('disable_inarray_validator'), however, I want to keep that validator without passing all my entries of the selectbox to my InputFilter. Also I didn't find anything in the Zend 2 documentation. I guess the solution must be something simple. Thanks in advance.
Note: Same happens when I add the InputFilter with the InputFilterManager to the form.
Please see my comment on your question first. Only thing I thought might work that I haven't tried to get this to work is:
$input->getFilterChain()
->attachByName('stringtrim')
or
$input->getFilterChain()
->attach(new StringTrim())

Why do issue view page requires an extra refresh to see the customfield value?

I am updating my custom field pro-grammatically if custom field is left blank. I found a question on stack related to this which helped in saving/updating custom field value correctly.I referred this stack question .
As I said I am updating custom field if it is left blank. So I have written some java code which checks if custom field is null if yes then I am generating some values using java code and updating and saving value in database. This all is working fine. I am doing this all when create issue.
But when issue page is rendered the respective custom field is not displayed,it need an extra page refresh for that. After page reload the custom field is rendered on page with correct value.
Any ideas? Why page reload is required ?
Can some point me to write direction ?
I am using JIRA 6.0.x
I am writing code in MyCustomField extends AbstractSingleFieldType class and using its getVelocityParameters method
Check your log files for errors seen the first time the screen is loaded? May also be errors shown in the JavaScript console? Otherwise strip everything back to be as simple as possible and then add complexity back in until it breaks in the same way.

Resources