Page 1 of 1

Jsconfig parameter doesn't work on certain routes

PostPosted: Thu Apr 03, 2025 11:16 am
by SBarnes
On the following route the jsconfig paramter gets ignored, this has been raised by a customer as this is happening on their api as well although routes under Queries work, so I suspect it releated to the fact that the data is being collected by the business object rather than ORM Lite and Auto Query.

For some reason they want the underscore for Ruby on Rails :cry: but I am not sure this is fixable bar trying to set the parameter globally and that might not work either.

Code: Select all
https://api.jiwa.com.au/Inventory/00000000040000000002?apikey=9vjoF4M5-gYVBWjoFyW9nlQieB9FhxpJkAsRJznB_Ok&jsconfig=EmitLowercaseUnderscoreNames:true

Re: Jsconfig parameter doesn't work on certain routes

PostPosted: Thu Apr 03, 2025 11:33 am
by Mike.Sheen
In a plugin in a class implementing IJiwaApplicationManagerPlugin, in the setup method just set the jsconfig property there - this will ensure all Jiwa business logic serialises with that configuration.

Code: Select all
ServiceStack.Text.JsConfig.EmitLowercaseUnderscoreNames= true;


We've done similar before to work-around the date format not being serialised as ISO8601 and it works fine.

Re: Jsconfig parameter doesn't work on certain routes

PostPosted: Thu Apr 03, 2025 11:40 am
by SBarnes
Thanks, Mike yes, I was aware of that, but I was trying to avoid setting it that way as the client has multiple integrations against the same api where in some cases they need the underscore and in others not, hence the trying to use the query string to do it.

Re: Jsconfig parameter doesn't work on certain routes  Topic is solved

PostPosted: Thu Apr 03, 2025 11:53 am
by Mike.Sheen
SBarnes wrote:Thanks, Mike yes, I was aware of that, but I was trying to avoid setting it that way as the client has multiple integrations against the same api where in some cases they need the underscore and in others not, hence the trying to use the query string to do it.


Ok, so then I'd try a response filter - either a typed response filter, or perhaps just a global response filter with a condition on the path - you would preserve the current value of the JSConfig property, set it to what you want and then re-serialise the DTO.

Re: Jsconfig parameter doesn't work on certain routes

PostPosted: Thu Apr 03, 2025 11:55 am
by SBarnes
Thanks for the idea