Does anyone know of a good OpenAPI documentation generator for Ktor? I see this small amount of documentation, but it's not super clear on how it works even with the attached
swagger-codegen-generators
.
I'm open to suggestions for how to do this; trying to explore the options that are out there
⬆️ This is very close to what I expect Ktor to support natively in the future @Aleksei Tirman [JB]
ribesg
01/26/2023, 2:07 PM
Here's an actual Ktor Resource I have defined in a production backend
Copy code
@Resource("{id}")
@Serializable
data class FileResource(val parent: FilesResource = FilesResource(), val id: FileId) {
// Swagger data
object Get : ResourceDescription by describeResource({
operationId = "getFile"
summary = "Gets an existing file's download URL"
tags += "File"
"id" pathParameter {
description = "The id of the file to get"
example = "file-id.pdf"
required = true
}
200 response {
json { schema(DownloadResponse("http://…/file-id.pdf")) }
}
})
// Swagger data
object Delete : ResourceDescription by describeResource({
operationId = "deleteFile"
summary = "Deletes an existing file"
tags += "File"
"id" pathParameter {
description = "The id of the file to delete"
example = "file-id.pdf"
required = true
}
200 response {
description = "File deleted"
}
})
@Serializable
data class DownloadResponse(val url: String)
}
m
Mark Vogel
01/26/2023, 3:26 PM
This is great! Thank you for all the replies I will definitely be trying these out