package Ġio . bk bn . k omp end ium . swagger Ċ Ċ import Ġio . ktor . features . NotFoundException Ċ import Ġio . ktor . http . content . ByteArray Content Ċ import Ġjava . net . URL Ċ import Ġorg . web j ars . Web Jar Asset Locator Ċ Ċ internal Ġfun ĠWeb Jar Asset Locator . get Swagger Resource ( path : ĠString ): ĠURL Ġ= ĊĠ Ġthis :: class . java . getResource ( getFull Path (" swagger - ui ", Ġpath ). let Ġ{ Ġif Ġ( it . startsWith ("/ ")) Ġit Ġelse Ġ"/ $ it " Ġ}) ĊĠĠĠ Ġ?: Ġthrow ĠNotFound Exception (" Resource Ġnot Ġfound : Ġ$ path ") Ċ Ċ internal Ġfun ĠWeb Jar Asset Locator . get Swagger Resource Content ( path : ĠString ): ĠByteArray Content Ġ= ĊĠ ĠByteArray Content ( get Swagger Resource ( path ). read Bytes ()) Ċ Ċ internal Ġfun ĠWeb Jar Asset Locator . get Swagger Index Content ( js Config : ĠJs Config ): ĠByteArray Content Ġ= ĠByteArray Content ( ĊĠĠĠ Ġget Swagger Resource ( path Ġ= Ġ" index . html "). read Text () ĊĠĠĠĠĠ Ġ. replace First (" url : Ġ\" https :// pet store . swagger . io / v 2 / swagger . json \", ", Ġ" urls : Ġ${ js Config . get Spec Urls Props ()}, ") ĊĠĠĠĠĠ Ġ. replace First (" deep Link ing : Ġtrue ", Ġjs Config . to Js Props ()) ĊĠĠĠĠĠ Ġ. let Ġ{ Ġcontent Ġ-> ĊĠĠĠĠĠĠĠ Ġjs Config . js Init ()?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġcontent . replace First (" window . ui Ġ= Ġui ", Ġ"$ it \ n \ t window . ui Ġ= Ġui ") ĊĠĠĠĠĠĠĠ Ġ} Ġ?: Ġcontent ĊĠĠĠĠĠ Ġ}. toByteArray () ĊĠ Ġ) Ċ