2

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

aosho235
  • 123
  • 1
  • 2
  • 15
  • You may have better luck asking this question in the Swagger UI repository https://github.com/swagger-api/swagger-ui/issues – Helen Sep 06 '19 at 14:18

1 Answers1

1

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

aosho235
  • 123
  • 1
  • 2
  • 15
  • Finally! After two hours of debugging, your answer worked for me. Thank you! As @Grin said at the link, the problem is: `Setter .value= is not working as we wanted because React library overrides the input value setter.` – soroushkavousi Jun 16 '22 at 15:18