tabilzad / ktor-docs-plugin Goto Github PK
View Code? Open in Web Editor NEWProvides Ktor Swagger support
Provides Ktor Swagger support
Route definitions could be extracted at runtime with the native api
fun Application.getAllRoutes(): List<Route> {
val root = plugin(Routing)
val allRoutes = allRoutes(root)
return allRoutes.filter { it.selector is HttpMethodRouteSelector }
}
fun allRoutes(root: Route): List<Route> {
return listOf(root) + root.children.flatMap { allRoutes(it) }
}
OpenAPI spec is not being generated properly for maps
If in https://github.com/tabilzad/ktor-docs-plugin/blob/7c3c3aa137aab645eb0956f68661283f0911ded0/create-plugin/src/test/resources/sources/Paths2.kt#L19C1-L19C41 change @KtorDocs to @KtorDocs(["tag2"]) then output json will not change
data class Sample(
@Json(name= "externalName")
val internalName: String
)
should account for the serializer specific naming convention.
I have a single @KtorDocs
annotation on my app like this
@KtorDocs
fun Application.topLevelRoutes() {
routing {
base()
articles()
}
}
i serve the swagger UI as described in the ktor docs like this
swaggerUI(path = "openapi", swaggerFile = "openapi.yaml") {
version = "5.17.2"
}
the first time i use run
or runshadow
the server fails to launch because the openapi file has yet to be generated
Exception in thread "main" java.io.FileNotFoundException: Swagger file not found: /home/ixtli/Public/project/kt/stavvy-sample-webserver/openapi.yaml
at io.ktor.server.plugins.swagger.SwaggerKt.swaggerUI(Swagger.kt:44)
at io.ktor.server.plugins.swagger.SwaggerKt.swaggerUI(Swagger.kt:36)
...
subsequent runs work fine, once the openapi yaml is present in the build dir
my gradle configuration relevant to this issue is
swagger {
documentation {
docsTitle = "Stavvy Example Ktor Server"
docsDescription = "Server Description Here!"
docsVersion = "1.0"
generateRequestSchemas = true
hideTransientFields = true
hidePrivateAndInternalFields = true
}
pluginOptions {
enabled = true
saveInBuild = true
format = "yaml"
}
}
sourceSets {
kotlin {
main {
resources {
srcDir(layout.buildDirectory.dir("openapi"))
}
}
}
}
it seems obvious to me that the task graph is wrong. perhaps the generation is a dependency of kotlin compilation where instead the AP should be run as an assembly dependency?
Where will I add given code in build.gradle.kts? it shows an error. Please add documentation for build.gradle.kts
swagger {
title = "Ktor Server"
description = "Ktor Server Description"
version = "1.0"
requestFeature = true
}
Just cloned the repo to try out the use-plugin example, but without changing anything, the build.gradle gives me this error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/tobias/Downloads/ktor-docs-plugin-master/use-plugin/build.gradle' line: 3
* What went wrong:
Plugin [id: 'io.github.tabilzad.ktor-docs-plugin-gradle'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 482ms
As already said, this is the cloned repo and it gave me this error while intellij was busy loading the gradle script.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.