Hello, do you have a documentation page to render ...
# ktor
v
Hello, do you have a documentation page to render swagger documentation with ktor please ?
1
d
The most similar thing I’m aware of, is this issue: https://github.com/ktorio/ktor/issues/453
v
Thank for your answer. But if I have already the swagger json file, is it possible to send swagger ui and the json to the client to render it ?
d
There is an experimental swagger support for creating ktor projects: https://kotlinlang.slack.com/archives/C0A974TJ9/p1531889740000139?thread_ts=1531889740.000139
v
I tried your solution with a swagger json 2.0 but that doesn’t work... nothing ça generated for swagger rendering
d
any error?
it’s experimental, but as far as I know if something is not supported an exception is thrown
v
No error just the swagger rendering not in the project generated. I will try another solution, how do you render html file and css please ? Just call.respondFile not work for this
d
That’s strange. Would be nice to troubleshoot. For HTML: https://ktor.io/features/templates/html-dsl.html A guide for creating a website rendering HTML here: https://ktor.io/quickstart/guides/website.html
v
I tried this call.respondFile(File(“documentationSwagger/index.html”)) but the file is not send...
d
an exception thrown?
That file exists?
v
No error I just received this {“result”: “documentationSwagger/index.html”} instead of the file
d
That looks strange
v
I have seen this page but it’s to create html in ktor. In my case I have already the file so I just wamt to send it 🙂
d
yep, that makes sense, respondFile should work
v
I have this : suspend fun ApplicationCall.respondSuccessJson(answer: Any, code: HttpStatusCode = HttpStatusCode.OK) = respondText(“”"{“result”: $answer}“”", ContentType.parse(“application/json”), code) so it’s like send file use this…
instead of send the file
d
tyr with
call.respondText(“hello”) to see if you are entering the right route?
v
Yes that works, I receive only hello in this case
d
and…
call.respondText(File("…").readText())
?
v
Ok you have right, ktor didn’t find the file because in this case I received no such file or directory… I will try to change the path
d
okay
v
Just another question, if I have to send js, css and html file, I need to start by which one please ?
d
I think I do not understand the question
usually the user request an html
that html references js and css and those files are downloaded
For that, normally you would use the static files feature: https://ktor.io/features/static-content.html
to map a local folder to a url path
v
Ok I understand, thank you again for your help !
simple smile 1
👌 1
d
Related to the swagger issue you had, I guess you were using windows: https://github.com/ktorio/ktor/issues/499#issuecomment-410365863 It should be fixed in the next version that will probably come next week 🙂
👍 1