forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ktor] Update generator to latest Ktor version OpenAPITools#14061
- Loading branch information
Showing
36 changed files
with
1,126 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
package {{packageName}} | ||
|
||
{{#featureMetrics}} | ||
import com.codahale.metrics.Slf4jReporter | ||
{{/featureMetrics}} | ||
import io.ktor.application.* | ||
import io.ktor.features.* | ||
import io.ktor.gson.* | ||
import io.ktor.server.application.* | ||
import io.ktor.serialization.gson.* | ||
import io.ktor.http.* | ||
{{#featureLocations}} | ||
import io.ktor.locations.* | ||
{{/featureLocations}} | ||
{{#featureResources}} | ||
import io.ktor.server.resources.* | ||
{{/featureResources}} | ||
{{#featureCORS}} | ||
import io.ktor.server.plugins.cors.routing.* | ||
{{/featureCORS}} | ||
{{#featureAutoHead}} | ||
import io.ktor.server.plugins.autohead.* | ||
{{/featureAutoHead}} | ||
{{#featureConditionalHeaders}} | ||
import io.ktor.server.plugins.conditionalheaders.* | ||
{{/featureConditionalHeaders}} | ||
{{#featureCompression}} | ||
import io.ktor.server.plugins.compression.* | ||
{{/featureCompression}} | ||
import io.ktor.server.plugins.contentnegotiation.* | ||
import io.ktor.server.plugins.defaultheaders.* | ||
{{#featureHSTS}} | ||
import io.ktor.server.plugins.hsts.* | ||
{{/featureHSTS}} | ||
{{#featureMetrics}} | ||
import io.ktor.metrics.dropwizard.* | ||
import com.codahale.metrics.Slf4jReporter | ||
import io.ktor.server.metrics.dropwizard.* | ||
import java.util.concurrent.TimeUnit | ||
{{/featureMetrics}} | ||
import io.ktor.routing.* | ||
import io.ktor.util.* | ||
import io.ktor.server.routing.* | ||
{{#hasAuthMethods}} | ||
import com.typesafe.config.ConfigFactory | ||
import io.ktor.auth.* | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.apache.Apache | ||
import io.ktor.config.HoconApplicationConfig | ||
import io.ktor.server.config.HoconApplicationConfig | ||
import io.ktor.server.auth.* | ||
import org.openapitools.server.infrastructure.* | ||
{{/hasAuthMethods}} | ||
{{#generateApis}}{{#apiInfo}}{{#apis}}import {{apiPackage}}.{{classname}} | ||
|
@@ -35,16 +48,12 @@ object HTTP { | |
} | ||
{{/hasAuthMethods}} | ||
|
||
@KtorExperimentalAPI | ||
{{#featureLocations}} | ||
@KtorExperimentalLocationsAPI | ||
{{/featureLocations}} | ||
fun Application.main() { | ||
install(DefaultHeaders) | ||
{{#featureMetrics}} | ||
install(DropwizardMetrics) { | ||
val reporter = Slf4jReporter.forRegistry(registry) | ||
.outputTo(log) | ||
.outputTo(this@main.log) | ||
.convertRatesTo(TimeUnit.SECONDS) | ||
.convertDurationsTo(TimeUnit.MILLISECONDS) | ||
.build() | ||
|
@@ -70,9 +79,9 @@ fun Application.main() { | |
{{#featureHSTS}} | ||
install(HSTS, ApplicationHstsConfiguration()) // see https://ktor.io/docs/hsts.html | ||
{{/featureHSTS}} | ||
{{#featureLocations}} | ||
install(Locations) // see https://ktor.io/docs/features-locations.html | ||
{{/featureLocations}} | ||
{{#featureResources}} | ||
install(Resources) | ||
{{/featureResources}} | ||
{{#hasAuthMethods}} | ||
install(Authentication) { | ||
{{#authMethods}} | ||
|
@@ -105,7 +114,7 @@ fun Application.main() { | |
{{^bodyAllowed}} | ||
oauth("{{name}}") { | ||
client = HttpClient(Apache) | ||
providerLookup = { ApplicationAuthProviders["{{{name}}}"] } | ||
providerLookup = { applicationAuthProvider([email protected]) } | ||
urlProvider = { _ -> | ||
// TODO: define a callback url here. | ||
"/" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.