From 0535620307757815eac20858410cdac69a4e970d Mon Sep 17 00:00:00 2001 From: Lukas Ruegner Date: Sun, 9 Jun 2024 13:14:00 +0200 Subject: [PATCH] cleanup, documentation, set version 3.0.0 --- README.md | 20 +++++++------ gradle.properties | 4 +-- .../smiley4/ktorswaggerui/SwaggerPlugin.kt | 2 +- .../builder/example/ExampleContext.kt | 12 ++++++++ .../builder/example/ExampleContextImpl.kt | 21 +++++++++++++- .../builder/openapi/ComponentsBuilder.kt | 4 +++ .../builder/openapi/ContactBuilder.kt | 4 +++ .../builder/openapi/ContentBuilder.kt | 5 ++++ .../openapi/ExternalDocumentationBuilder.kt | 4 +++ .../builder/openapi/HeaderBuilder.kt | 5 ++++ .../builder/openapi/InfoBuilder.kt | 4 +++ .../builder/openapi/LicenseBuilder.kt | 4 +++ .../builder/openapi/OAuthFlowsBuilder.kt | 4 +++ .../builder/openapi/OpenApiBuilder.kt | 4 +++ .../builder/openapi/OperationBuilder.kt | 4 +++ .../builder/openapi/OperationTagsBuilder.kt | 3 ++ .../builder/openapi/ParameterBuilder.kt | 4 +++ .../builder/openapi/PathBuilder.kt | 4 +++ .../builder/openapi/PathsBuilder.kt | 4 +++ .../builder/openapi/RequestBodyBuilder.kt | 4 +++ .../builder/openapi/ResponseBuilder.kt | 4 +++ .../builder/openapi/ResponsesBuilder.kt | 4 +++ .../openapi/SecurityRequirementsBuilder.kt | 9 ++++-- .../builder/openapi/SecuritySchemesBuilder.kt | 4 +++ .../builder/openapi/ServerBuilder.kt | 4 +++ .../builder/openapi/TagBuilder.kt | 4 +++ .../TagExternalDocumentationBuilder.kt | 4 +++ .../builder/route/RouteCollector.kt | 3 ++ .../builder/schema/SchemaContext.kt | 11 +++++++ .../ktorswaggerui/data/AuthKeyLocation.kt | 3 ++ .../smiley4/ktorswaggerui/data/AuthType.kt | 3 ++ .../smiley4/ktorswaggerui/data/ContactData.kt | 3 ++ .../ktorswaggerui/data/ExampleDescriptor.kt | 17 +++++++++++ .../ktorswaggerui/data/ExternalDocsData.kt | 3 ++ .../smiley4/ktorswaggerui/data/InfoData.kt | 3 ++ .../smiley4/ktorswaggerui/data/LicenseData.kt | 3 ++ .../ktorswaggerui/data/OpenApiBaseBodyData.kt | 11 +++++++ .../ktorswaggerui/data/OpenApiHeaderData.kt | 3 ++ .../data/OpenApiMultipartPartData.kt | 3 ++ .../ktorswaggerui/data/OpenApiRequestData.kt | 3 ++ .../data/OpenApiRequestParameterData.kt | 3 ++ .../ktorswaggerui/data/OpenApiResponseData.kt | 3 ++ .../ktorswaggerui/data/OpenApiRouteData.kt | 3 ++ .../ktorswaggerui/data/OpenIdOAuthFlowData.kt | 3 ++ .../data/OpenIdOAuthFlowsData.kt | 3 ++ .../ktorswaggerui/data/ParameterLocation.kt | 3 ++ .../smiley4/ktorswaggerui/data/PathFilter.kt | 3 ++ .../ktorswaggerui/data/PluginConfigData.kt | 3 ++ .../smiley4/ktorswaggerui/data/PostBuild.kt | 1 + .../ktorswaggerui/data/SchemaConfigData.kt | 4 ++- .../ktorswaggerui/data/SecurityData.kt | 3 ++ .../ktorswaggerui/data/SecuritySchemeData.kt | 3 ++ .../smiley4/ktorswaggerui/data/ServerData.kt | 3 ++ .../ktorswaggerui/data/ServerVariableData.kt | 4 +++ .../ktorswaggerui/data/SpecAssigner.kt | 1 + .../ktorswaggerui/data/SwaggerUIData.kt | 3 ++ .../ktorswaggerui/data/SwaggerUiSort.kt | 7 ++--- .../data/SwaggerUiSyntaxHighlight.kt | 3 ++ .../smiley4/ktorswaggerui/data/TagData.kt | 3 ++ .../ktorswaggerui/data/TagGenerator.kt | 1 + .../smiley4/ktorswaggerui/data/TagsData.kt | 3 ++ .../ktorswaggerui/data/TypeDescriptor.kt | 29 +++++++++++++++++++ .../ktorswaggerui/dsl/config/OpenApiInfo.kt | 3 ++ .../ktorswaggerui/dsl/config/SwaggerUIDsl.kt | 4 ++- .../ktorswaggerui/dsl/routes/OpenApiHeader.kt | 4 ++- .../dsl/routes/OpenApiRequest.kt | 4 ++- .../dsl/routes/OpenApiRequestParameter.kt | 4 ++- .../ktorswaggerui/dsl/routes/OpenApiRoute.kt | 3 ++ .../smiley4/ktorswaggerui/routing/routing.kt | 7 ++++- .../builder/OpenApiBuilderTest.kt | 3 +- .../builder/OperationBuilderTest.kt | 2 +- .../ktorswaggerui/builder/PathsBuilderTest.kt | 2 +- todo.txt | 5 ---- 73 files changed, 320 insertions(+), 35 deletions(-) delete mode 100644 todo.txt diff --git a/README.md b/README.md index 03ca9a9..b65f7d0 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ This library provides a Ktor plugin to document routes, generate an OpenApi Spec ## Features - minimally invasive (no immediate change to existing code required) -- provides swagger-ui with no initial configuration required -- supports most of the [OpenAPI 3.0.3 Specification](https://swagger.io/specification/) -- automatic json-schema generation from arbitrary types/classes for bodies and parameters -- use custom encoder/serializers for examples and json-schemas -- provide custom schemas or a custom schema-builder -- external/custom json-schemas for bodies -- protect Swagger-UI and OpenApi-Spec with custom authentication +- provides swagger-ui and openapi-spec with minimal configuration +- supports most of the [OpenAPI 3.1.0 Specification](https://swagger.io/specification/) +- automatic [json-schema generation](https://github.com/SMILEY4/schema-kenerator) from arbitrary types/classes for bodies and parameters + - supports generics, inheritance, collections, ... + - support for Jackson-annotations and swagger Schema-annotations (optional) + - use with reflection or kotlinx-serialization + - customizable schema-generation ## Documentation @@ -32,8 +32,10 @@ dependencies { ``` -## Example -Full examples can be found in [src/test/examples](https://github.com/SMILEY4/ktor-swagger-ui/tree/develop/src/test/kotlin/io/github/smiley4/ktorswaggerui/examples). +## Examples + +Runnable examples can be found in [ktor-swagger-ui-examples/src/main/kotlin/io/github/smiley4/ktorswaggerui/examples](https://github.com/SMILEY4/ktor-swagger-ui/tree/release/ktor-swagger-ui-examples/src/main/kotlin/io/github/smiley4/ktorswaggerui/examples). + ### Configuration diff --git a/gradle.properties b/gradle.properties index 4f4df1a..dad08b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ kotlin.code.style=official # project id projectGroupId=io.github.smiley4 projectArtifactIdBase=ktor-swagger-ui -projectVersion=3.0.0-beta3 +projectVersion=3.0.0 # publishing information projectNameBase=Ktor Swagger UI @@ -19,7 +19,7 @@ projectDeveloperUrl=https://github.com/SMILEY4 versionKtor=2.3.11 versionSwaggerUI=5.17.11 versionSwaggerParser=2.1.22 -versionSchemaKenerator=0.4.0 +versionSchemaKenerator=1.0.0 versionKotlinLogging=3.0.5 versionKotest=5.8.0 versionKotlinTest=1.8.21 diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/SwaggerPlugin.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/SwaggerPlugin.kt index cb16b0c..6833c6a 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/SwaggerPlugin.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/SwaggerPlugin.kt @@ -94,7 +94,7 @@ private fun buildOpenApiSpec(pluginConfig: PluginConfigData, routes: List } diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/example/ExampleContextImpl.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/example/ExampleContextImpl.kt index 45038d4..5673180 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/example/ExampleContextImpl.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/example/ExampleContextImpl.kt @@ -9,24 +9,39 @@ import io.github.smiley4.ktorswaggerui.data.SwaggerExampleDescriptor import io.github.smiley4.ktorswaggerui.data.ValueExampleDescriptor import io.swagger.v3.oas.models.examples.Example +/** + * Implementation of an [ExampleContext]. + */ class ExampleContextImpl : ExampleContext { private val rootExamples = mutableMapOf() private val componentExamples = mutableMapOf() - fun addGlobal(config: ExampleConfigData) { + + /** + * Add all global/shared examples from the config that are placed in the components-section of the openapi-spec + */ + fun addShared(config: ExampleConfigData) { config.sharedExamples.forEach { (_, exampleDescriptor) -> val example = generateExample(exampleDescriptor) componentExamples[exampleDescriptor.name] = example } } + + /** + * Collect and add all examples for the given routes + */ fun add(routes: Collection) { collectExampleDescriptors(routes).forEach { exampleDescriptor -> rootExamples[exampleDescriptor] = generateExample(exampleDescriptor) } } + + /** + * Collect all [ExampleDescriptor]s from the given routes + */ private fun collectExampleDescriptors(routes: Collection): List { val descriptors = mutableListOf() routes @@ -53,6 +68,10 @@ class ExampleContextImpl : ExampleContext { return descriptors } + + /** + * Generate a swagger [Example] from the given [ExampleDescriptor] + */ private fun generateExample(exampleDescriptor: ExampleDescriptor): Example { return when (exampleDescriptor) { is ValueExampleDescriptor -> Example().also { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ComponentsBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ComponentsBuilder.kt index 4404018..c39dc3b 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ComponentsBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ComponentsBuilder.kt @@ -5,6 +5,10 @@ import io.swagger.v3.oas.models.Components import io.swagger.v3.oas.models.examples.Example import io.swagger.v3.oas.models.media.Schema +/** + * Builds the openapi [Components]-object containing shared reusable schemas and examples. + * See [OpenAPI Specification - Components Object](https://swagger.io/specification/#components-object). + */ class ComponentsBuilder( private val config: PluginConfigData, private val securitySchemesBuilder: SecuritySchemesBuilder diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContactBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContactBuilder.kt index 5fc0e48..b09e227 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContactBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContactBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.ContactData import io.swagger.v3.oas.models.info.Contact +/** + * Builds the openapi [Contact]-object. Holds Contact information for the exposed API. + * See [OpenAPI Specification - Contact Object](https://swagger.io/specification/#contact-object). + */ class ContactBuilder { fun build(contact: ContactData): Contact = diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContentBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContentBuilder.kt index 64ea8bd..bd9b970 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContentBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ContentBuilder.kt @@ -12,6 +12,11 @@ import io.swagger.v3.oas.models.media.MediaType import io.swagger.v3.oas.models.media.Schema import kotlin.collections.set +/** + * Builds the openapi [Content]-object for request and response bodies. + * See [OpenAPI Specification - Request Body Object](https://swagger.io/specification/#request-body-object) + * and [OpenAPI Specification - Response Object](https://swagger.io/specification/#response-object). + */ class ContentBuilder( private val schemaContext: SchemaContext, private val exampleContext: ExampleContext, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ExternalDocumentationBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ExternalDocumentationBuilder.kt index 49f4fd2..437dd49 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ExternalDocumentationBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ExternalDocumentationBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.ExternalDocsData import io.swagger.v3.oas.models.ExternalDocumentation +/** + * Build the openapi [ExternalDocumentation]-object. Allows referencing an external resource for extended documentation. + * See [OpenAPI Specification - External Documentation Object](https://swagger.io/specification/#external-documentation-object). + */ class ExternalDocumentationBuilder { fun build(externalDocs: ExternalDocsData): ExternalDocumentation = diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/HeaderBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/HeaderBuilder.kt index 63330ea..0ecece3 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/HeaderBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/HeaderBuilder.kt @@ -2,8 +2,13 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.builder.schema.SchemaContext import io.github.smiley4.ktorswaggerui.data.OpenApiHeaderData +import io.swagger.v3.oas.models.ExternalDocumentation import io.swagger.v3.oas.models.headers.Header +/** + * Build the openapi [Header]-object. + * See [OpenAPI Specification - Header Object](https://swagger.io/specification/#header-object). + */ class HeaderBuilder( private val schemaContext: SchemaContext ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/InfoBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/InfoBuilder.kt index 0fb0e99..e620be4 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/InfoBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/InfoBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.InfoData import io.swagger.v3.oas.models.info.Info +/** + * Build the openapi [Info]-object. Holds metadata about the API. + * See [OpenAPI Specification - Info Object](https://swagger.io/specification/#info-object). + */ class InfoBuilder( private val contactBuilder: ContactBuilder, private val licenseBuilder: LicenseBuilder diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/LicenseBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/LicenseBuilder.kt index 056662b..a6d5e1f 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/LicenseBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/LicenseBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.LicenseData import io.swagger.v3.oas.models.info.License +/** + * Build the openapi [License]-object. Holds license information for the exposed API. + * See [OpenAPI Specification - License Object](https://swagger.io/specification/#license-object). + */ class LicenseBuilder { fun build(license: LicenseData): License = diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OAuthFlowsBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OAuthFlowsBuilder.kt index c8f8c96..4469201 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OAuthFlowsBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OAuthFlowsBuilder.kt @@ -6,6 +6,10 @@ import io.swagger.v3.oas.models.security.OAuthFlow import io.swagger.v3.oas.models.security.OAuthFlows import io.swagger.v3.oas.models.security.Scopes +/** + * Build the openapi [OAuthFlows]-object. Holds configuration of the supported OAuth Flows. + * See [OpenAPI Specification - OAuth Flows Object](https://swagger.io/specification/#oauth-flows-object). + */ class OAuthFlowsBuilder { fun build(flows: OpenIdOAuthFlowsData): OAuthFlows { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OpenApiBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OpenApiBuilder.kt index b0830ab..359217a 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OpenApiBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OpenApiBuilder.kt @@ -7,6 +7,10 @@ import io.github.smiley4.ktorswaggerui.builder.schema.SchemaContext import io.swagger.v3.oas.models.OpenAPI import io.swagger.v3.oas.models.SpecVersion +/** + * Build the openapi [OpenAPI]-object. Is the root of the openapi document. + * See [OpenAPI Specification - OpenAPI Object](https://swagger.io/specification/#openapi-object). + */ class OpenApiBuilder( private val config: PluginConfigData, private val schemaContext: SchemaContext, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationBuilder.kt index 339faed..d793cb7 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.builder.route.RouteMeta import io.swagger.v3.oas.models.Operation +/** + * Build the openapi [Operation]-object. Holds information describing a single API operation on a path. + * See [OpenAPI Specification - Operation Object](https://swagger.io/specification/#operation-object). + */ class OperationBuilder( private val operationTagsBuilder: OperationTagsBuilder, private val parameterBuilder: ParameterBuilder, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationTagsBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationTagsBuilder.kt index f941bff..3e8f7bf 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationTagsBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/OperationTagsBuilder.kt @@ -3,6 +3,9 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.PluginConfigData import io.github.smiley4.ktorswaggerui.builder.route.RouteMeta +/** + * Builds the list of tags for a single route. + */ class OperationTagsBuilder( private val config: PluginConfigData ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ParameterBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ParameterBuilder.kt index 221b33d..6f852c6 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ParameterBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ParameterBuilder.kt @@ -6,6 +6,10 @@ import io.github.smiley4.ktorswaggerui.data.OpenApiRequestParameterData import io.github.smiley4.ktorswaggerui.data.ParameterLocation import io.swagger.v3.oas.models.parameters.Parameter +/** + * Build the openapi [Parameter]-object. Holds information describing a single operation (query, path or header) parameter. + * See [OpenAPI Specification - Parameter Object](https://swagger.io/specification/#parameter-object). + */ class ParameterBuilder( private val schemaContext: SchemaContext, private val exampleContext: ExampleContext diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathBuilder.kt index a6c5c93..a0328e5 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathBuilder.kt @@ -4,6 +4,10 @@ import io.github.smiley4.ktorswaggerui.builder.route.RouteMeta import io.ktor.http.HttpMethod import io.swagger.v3.oas.models.PathItem +/** + * Build the openapi [PathItem]-object. Holds information describing the operations available on a single path. + * See [OpenAPI Specification - Path Item Object](https://swagger.io/specification/#path-item-object). + */ class PathBuilder( private val operationBuilder: OperationBuilder ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathsBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathsBuilder.kt index 46a3c6e..f34ad9f 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathsBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/PathsBuilder.kt @@ -4,6 +4,10 @@ import io.github.smiley4.ktorswaggerui.builder.route.RouteMeta import io.swagger.v3.oas.models.PathItem import io.swagger.v3.oas.models.Paths +/** + * Build the openapi [Paths]-object. Holds the relative paths to the individual endpoints and their operations. + * See [OpenAPI Specification - Paths Object](https://swagger.io/specification/#paths-object). + */ class PathsBuilder( private val pathBuilder: PathBuilder ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/RequestBodyBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/RequestBodyBuilder.kt index 8795b1b..9e5c82f 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/RequestBodyBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/RequestBodyBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.OpenApiBaseBodyData import io.swagger.v3.oas.models.parameters.RequestBody +/** + * Build the openapi [RequestBody]-object. Holds information describing a single request body. + * See [OpenAPI Specification - Request Body Object](https://swagger.io/specification/#request-body-object). + */ class RequestBodyBuilder( private val contentBuilder: ContentBuilder ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponseBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponseBuilder.kt index e70d69b..27512d4 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponseBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponseBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.OpenApiResponseData import io.swagger.v3.oas.models.responses.ApiResponse +/** + * Build the openapi [ApiResponse]-objects by status-code. Holds information describing status-codes and responses from an API Operation. + * See [OpenAPI Specification - Response Object](https://swagger.io/specification/#response-object). + */ class ResponseBuilder( private val headerBuilder: HeaderBuilder, private val contentBuilder: ContentBuilder diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponsesBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponsesBuilder.kt index 3078c2b..957dacc 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponsesBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ResponsesBuilder.kt @@ -5,6 +5,10 @@ import io.github.smiley4.ktorswaggerui.data.PluginConfigData import io.ktor.http.HttpStatusCode import io.swagger.v3.oas.models.responses.ApiResponses +/** + * Build the openapi [ApiResponses]-object. A container for the expected responses of an operation. + * See [OpenAPI Specification - Responses Object](https://swagger.io/specification/#responses-object). + */ class ResponsesBuilder( private val responseBuilder: ResponseBuilder, private val config: PluginConfigData diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecurityRequirementsBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecurityRequirementsBuilder.kt index db143ec..52d3ec2 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecurityRequirementsBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecurityRequirementsBuilder.kt @@ -4,18 +4,21 @@ import io.github.smiley4.ktorswaggerui.builder.route.RouteMeta import io.github.smiley4.ktorswaggerui.data.PluginConfigData import io.swagger.v3.oas.models.security.SecurityRequirement +/** + * Build the openapi [SecurityRequirement]-objects. + * See [OpenAPI Specification - Security Requirement Object](https://swagger.io/specification/#security-requirement-object). + */ class SecurityRequirementsBuilder( private val config: PluginConfigData ) { fun build(route: RouteMeta): List { - val securitySchemes = buildSet { + return buildSet { addAll(route.documentation.securitySchemeNames) if(route.documentation.securitySchemeNames.isEmpty()) { addAll(config.securityConfig.defaultSecuritySchemeNames) } - } - return securitySchemes.map { + }.map { SecurityRequirement().apply { addList(it, emptyList()) } diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecuritySchemesBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecuritySchemesBuilder.kt index 086aa89..1a354e8 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecuritySchemesBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/SecuritySchemesBuilder.kt @@ -4,6 +4,10 @@ import io.github.smiley4.ktorswaggerui.data.AuthType import io.github.smiley4.ktorswaggerui.data.SecuritySchemeData import io.swagger.v3.oas.models.security.SecurityScheme +/** + * Build the openapi [SecurityScheme]-objects with their names. Holds information defining security schemes that can be used by operations. + * See [OpenAPI Specification - Security Scheme Object](https://swagger.io/specification/#security-scheme-object). + */ class SecuritySchemesBuilder( private val oAuthFlowsBuilder: OAuthFlowsBuilder ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ServerBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ServerBuilder.kt index dfe2ba6..09d41fe 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ServerBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/ServerBuilder.kt @@ -5,6 +5,10 @@ import io.swagger.v3.oas.models.servers.Server import io.swagger.v3.oas.models.servers.ServerVariable import io.swagger.v3.oas.models.servers.ServerVariables +/** + * Build the openapi [Server]-object. Holds information representing a Server. + * See [OpenAPI Specification - Server Object](https://swagger.io/specification/#server-object). + */ class ServerBuilder { fun build(server: ServerData): Server = diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagBuilder.kt index d550e6a..c1d9ed4 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagBuilder.kt @@ -3,6 +3,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.github.smiley4.ktorswaggerui.data.TagData import io.swagger.v3.oas.models.tags.Tag +/** + * Build the openapi [Tag]-object. Holds metadata of a single tag. + * See [OpenAPI Specification - Tag Object](https://swagger.io/specification/#tag-object). + */ class TagBuilder( private val tagExternalDocumentationBuilder: TagExternalDocumentationBuilder ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagExternalDocumentationBuilder.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagExternalDocumentationBuilder.kt index 4e53c08..a388349 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagExternalDocumentationBuilder.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/openapi/TagExternalDocumentationBuilder.kt @@ -2,6 +2,10 @@ package io.github.smiley4.ktorswaggerui.builder.openapi import io.swagger.v3.oas.models.ExternalDocumentation +/** + * Build the openapi [ExternalDocumentation]-object for a tag. + * See [OpenAPI Specification - External Documentation Object](https://swagger.io/specification/#external-documentation-object). + */ class TagExternalDocumentationBuilder { fun build(url: String, description: String): ExternalDocumentation = diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/route/RouteCollector.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/route/RouteCollector.kt index a225882..da25fd3 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/route/RouteCollector.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/route/RouteCollector.kt @@ -15,6 +15,9 @@ import io.ktor.server.routing.RouteSelector import io.ktor.server.routing.TrailingSlashRouteSelector import kotlin.reflect.full.isSubclassOf +/** + * Collect all routes from the given application + */ class RouteCollector( private val routeDocumentationMerger: RouteDocumentationMerger ) { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/schema/SchemaContext.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/schema/SchemaContext.kt index 89f2e53..3af0259 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/schema/SchemaContext.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/builder/schema/SchemaContext.kt @@ -3,7 +3,18 @@ package io.github.smiley4.ktorswaggerui.builder.schema import io.github.smiley4.ktorswaggerui.data.TypeDescriptor import io.swagger.v3.oas.models.media.Schema +/** + * Provides schemas for an openapi-spec + */ interface SchemaContext { + + /** + * Get a [Schema] (or a ref to a schema) by its [TypeDescriptor] + */ fun getSchema(typeDescriptor: TypeDescriptor): Schema<*> + + /** + * Get all schemas placed in the components-section of the spec. + */ fun getComponentSection(): Map> } diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthKeyLocation.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthKeyLocation.kt index d94ab76..5865f60 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthKeyLocation.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthKeyLocation.kt @@ -2,6 +2,9 @@ package io.github.smiley4.ktorswaggerui.data import io.swagger.v3.oas.models.security.SecurityScheme +/** + * The locations of the API key. + */ enum class AuthKeyLocation(val swaggerType: SecurityScheme.In) { QUERY(SecurityScheme.In.QUERY), HEADER(SecurityScheme.In.HEADER), diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthType.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthType.kt index 897ae47..e2f053e 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthType.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/AuthType.kt @@ -2,6 +2,9 @@ package io.github.smiley4.ktorswaggerui.data import io.swagger.v3.oas.models.security.SecurityScheme +/** + * The type of security schemes + */ enum class AuthType(val swaggerType: SecurityScheme.Type) { API_KEY(SecurityScheme.Type.APIKEY), HTTP(SecurityScheme.Type.HTTP), diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ContactData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ContactData.kt index 4a5f696..920ecaf 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ContactData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ContactData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Contact Object](https://swagger.io/specification/#contact-object). + */ data class ContactData( val name: String?, val url: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExampleDescriptor.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExampleDescriptor.kt index 59d4a4d..dfbe272 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExampleDescriptor.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExampleDescriptor.kt @@ -2,10 +2,17 @@ package io.github.smiley4.ktorswaggerui.data import io.swagger.v3.oas.models.examples.Example +/** + * Identifier and description of an example + */ sealed class ExampleDescriptor( val name: String, ) + +/** + * Describes an example as an object. + */ class ValueExampleDescriptor( name: String, val value: Any?, @@ -13,6 +20,16 @@ class ValueExampleDescriptor( val description: String? = null, ) : ExampleDescriptor(name) + +/** + * Describes a reference to a shared example placed in the components section + * @param name the name of the example in the operation + * @param refName the name/id of the example to reference in the components section + */ class RefExampleDescriptor(name: String, val refName: String) : ExampleDescriptor(name) + +/** + * Describes an example as a swagger [Example]-object + */ class SwaggerExampleDescriptor(name: String, val example: Example) : ExampleDescriptor(name) diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExternalDocsData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExternalDocsData.kt index 8ef5db0..ac3d72a 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExternalDocsData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ExternalDocsData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - External Documentation Object](https://swagger.io/specification/#external-documentation-object). + */ data class ExternalDocsData( val url: String, val description: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/InfoData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/InfoData.kt index c8ee025..4de183a 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/InfoData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/InfoData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Info Object](https://swagger.io/specification/#info-object). + */ data class InfoData( val title: String, val version: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/LicenseData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/LicenseData.kt index 5ae2002..bea8f45 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/LicenseData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/LicenseData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - License Object](https://swagger.io/specification/#license-object). + */ data class LicenseData( val name: String?, val url: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiBaseBodyData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiBaseBodyData.kt index 25489b3..eb91c3d 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiBaseBodyData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiBaseBodyData.kt @@ -2,12 +2,19 @@ package io.github.smiley4.ktorswaggerui.data import io.ktor.http.ContentType +/** + * The common information for request and response bodies. + */ sealed class OpenApiBaseBodyData( val description: String?, val required: Boolean, val mediaTypes: Set, ) + +/** + * Information for a "simple" request or response body. + */ class OpenApiSimpleBodyData( description: String?, required: Boolean, @@ -16,6 +23,10 @@ class OpenApiSimpleBodyData( val examples: List ) : OpenApiBaseBodyData(description, required, mediaTypes) + +/** + * Information for a multipart request or response body. + */ class OpenApiMultipartBodyData( description: String?, required: Boolean, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiHeaderData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiHeaderData.kt index 08eb738..aa4c4f9 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiHeaderData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiHeaderData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Header Object](https://swagger.io/specification/#header-object). + */ data class OpenApiHeaderData( val description: String?, val type: TypeDescriptor?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiMultipartPartData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiMultipartPartData.kt index 7b1e7a3..4f2da8c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiMultipartPartData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiMultipartPartData.kt @@ -2,6 +2,9 @@ package io.github.smiley4.ktorswaggerui.data import io.ktor.http.ContentType +/** + * Information about a part of a multipart request or response body. + */ data class OpenApiMultipartPartData( val name: String, val type: TypeDescriptor, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestData.kt index 0f6a289..6405acc 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Information about a request + */ data class OpenApiRequestData( val parameters: List, val body: OpenApiBaseBodyData?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestParameterData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestParameterData.kt index 6946d1c..5f7f83c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestParameterData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRequestParameterData.kt @@ -2,6 +2,9 @@ package io.github.smiley4.ktorswaggerui.data import io.swagger.v3.oas.models.parameters.Parameter +/** + * Information about a request (query, path or header) parameter. + */ data class OpenApiRequestParameterData( val name: String, val type: TypeDescriptor, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiResponseData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiResponseData.kt index 60a8e8d..6693df3 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiResponseData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiResponseData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Information about a response for a status-code. + */ data class OpenApiResponseData( val statusCode: String, val description: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRouteData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRouteData.kt index 1add5d6..67364ef 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRouteData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenApiRouteData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Information about a single route. + */ data class OpenApiRouteData( val specId: String?, val tags: Set, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowData.kt index 3072dec..a9563d2 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - OAuth Flow Object](https://swagger.io/specification/#oauth-flow-object). + */ data class OpenIdOAuthFlowData( val authorizationUrl: String? = null, val tokenUrl: String? = null, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowsData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowsData.kt index 44acedf..639820a 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowsData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/OpenIdOAuthFlowsData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - OAuth Flows Object](https://swagger.io/specification/#oauth-flows-object). + */ data class OpenIdOAuthFlowsData( val implicit: OpenIdOAuthFlowData?, val password: OpenIdOAuthFlowData?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ParameterLocation.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ParameterLocation.kt index 5577540..7052726 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ParameterLocation.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ParameterLocation.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Locations for request parameters. + */ enum class ParameterLocation { QUERY, HEADER, PATH } diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PathFilter.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PathFilter.kt index 12b9552..6eaa326 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PathFilter.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PathFilter.kt @@ -2,4 +2,7 @@ package io.github.smiley4.ktorswaggerui.data import io.ktor.http.HttpMethod +/** + * Filters paths to determine which to include (return 'true') in the spec and which to hide (return 'true'). + */ typealias PathFilter = (method: HttpMethod, url: List) -> Boolean diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PluginConfigData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PluginConfigData.kt index 2221b98..1ba537c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PluginConfigData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PluginConfigData.kt @@ -3,6 +3,9 @@ package io.github.smiley4.ktorswaggerui.data import io.github.smiley4.ktorswaggerui.dsl.config.PluginConfigDsl import kotlin.reflect.KClass +/** + * Complete plugin configuration + */ data class PluginConfigData( val specAssigner: SpecAssigner, val pathFilter: PathFilter, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PostBuild.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PostBuild.kt index 3865e46..5934a97 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PostBuild.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/PostBuild.kt @@ -3,6 +3,7 @@ package io.github.smiley4.ktorswaggerui.data import io.swagger.v3.oas.models.OpenAPI /** + * Function executed after building the openapi-spec. * @author yuefeng in 2024/3/25. */ typealias PostBuild = (openApi: OpenAPI) -> Unit diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SchemaConfigData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SchemaConfigData.kt index d785074..807eb0c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SchemaConfigData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SchemaConfigData.kt @@ -12,7 +12,9 @@ import io.github.smiley4.schemakenerator.swagger.handleCoreAnnotations import io.github.smiley4.schemakenerator.swagger.withAutoTitle import kotlin.reflect.KType - +/** + * Common configuration for schemas. + */ data class SchemaConfigData( val schemas: Map, val generator: (type: KType) -> CompiledSwaggerSchema, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecurityData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecurityData.kt index db09ff8..ee66378 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecurityData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecurityData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Common security configuration information. + */ data class SecurityData( val defaultUnauthorizedResponse: OpenApiResponseData?, val defaultSecuritySchemeNames: Set, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecuritySchemeData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecuritySchemeData.kt index 8537866..ddb0505 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecuritySchemeData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SecuritySchemeData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Security Scheme Object](https://swagger.io/specification/#security-scheme-object). + */ data class SecuritySchemeData( val schemeName: String, val type: AuthType?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerData.kt index 8fec541..7e9e334 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Server Object](https://swagger.io/specification/#server-object). + */ data class ServerData( val url: String, val description: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerVariableData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerVariableData.kt index 415c98e..c61ecc2 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerVariableData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/ServerVariableData.kt @@ -1,5 +1,9 @@ package io.github.smiley4.ktorswaggerui.data + +/** + * See [OpenAPI Specification - Server Variable Object](https://swagger.io/specification/#server-variable-object). + */ data class ServerVariableData( val name: String, val enum: Set, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SpecAssigner.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SpecAssigner.kt index 28a5e84..f87522d 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SpecAssigner.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SpecAssigner.kt @@ -1,6 +1,7 @@ package io.github.smiley4.ktorswaggerui.data /** + * Assigns (unassigned) routes to api-specs. * url - the parts of the route-url split at all `/`. * tags - the tags assigned to the route */ diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUIData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUIData.kt index cf306c8..c57dfb2 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUIData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUIData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Common configuration for the swagger-ui. + */ data class SwaggerUIData( val validatorUrl: String?, val displayOperationId: Boolean, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSort.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSort.kt index 84a40b1..8dccbc5 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSort.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSort.kt @@ -1,18 +1,17 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Determines the order to sort the operations in the swagger-ui. + */ enum class SwaggerUiSort(val value: String) { /** * The order returned by the server unchanged */ NONE("undefined"), - - /** * sort by paths alphanumerically */ ALPHANUMERICALLY("alpha"), - - /** * sort by HTTP method */ diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSyntaxHighlight.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSyntaxHighlight.kt index f31ffcc..07c17db 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSyntaxHighlight.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/SwaggerUiSyntaxHighlight.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * The syntax-highlight theme to use for code-blocks in swagger-ui. + */ enum class SwaggerUiSyntaxHighlight(val value: String) { DISABLED("disabled"), AGATE("agate"), diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagData.kt index 29b30b6..60b438f 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * See [OpenAPI Specification - Tag Object](https://swagger.io/specification/#tag-object). + */ data class TagData( val name: String, val description: String?, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagGenerator.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagGenerator.kt index 6ba542b..0a6372b 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagGenerator.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagGenerator.kt @@ -1,6 +1,7 @@ package io.github.smiley4.ktorswaggerui.data /** + * Generates additional tags for routes. * url - the parts of the route-url split at all `/`. * return a collection of tags. "Null"-entries will be ignored. */ diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagsData.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagsData.kt index abce2eb..d54479e 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagsData.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TagsData.kt @@ -1,5 +1,8 @@ package io.github.smiley4.ktorswaggerui.data +/** + * Common configuration for tags. + */ data class TagsData( val tags: List, val generator: TagGenerator, diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TypeDescriptor.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TypeDescriptor.kt index 2b9a028..69d4b4c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TypeDescriptor.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/data/TypeDescriptor.kt @@ -4,12 +4,41 @@ import io.swagger.v3.oas.models.media.Schema import kotlin.reflect.KType import kotlin.reflect.typeOf +/** + * Describes and identifies types and schemas. + */ sealed interface TypeDescriptor + + +/** + * Describes a type from a swagger [Schema] + */ class SwaggerTypeDescriptor(val schema: Schema<*>) : TypeDescriptor + + +/** + * Describes a type from a kotlin [KType] + */ class KTypeDescriptor(val type: KType) : TypeDescriptor + +/** + * Describes an array of types. + */ class ArrayTypeDescriptor(val type: TypeDescriptor) : TypeDescriptor + +/** + * Describes an object matching any of the given types. + */ class AnyOfTypeDescriptor(val types: List) : TypeDescriptor + +/** + * Describes an empty type/schema. + */ class EmptyTypeDescriptor : TypeDescriptor + +/** + * Describes a reference to a schema in the component section. + */ class RefTypeDescriptor(val schemaId: String) : TypeDescriptor inline fun type() = KTypeDescriptor(typeOf()) diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/OpenApiInfo.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/OpenApiInfo.kt index 83923bd..f78facd 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/OpenApiInfo.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/OpenApiInfo.kt @@ -7,6 +7,9 @@ import io.github.smiley4.ktorswaggerui.data.InfoData import io.github.smiley4.ktorswaggerui.data.LicenseData import io.github.smiley4.ktorswaggerui.dsl.OpenApiDslMarker +/** + * Basic information for the exposed API. + */ @OpenApiDslMarker class OpenApiInfo { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/SwaggerUIDsl.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/SwaggerUIDsl.kt index 53c54c4..1aa4fe0 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/SwaggerUIDsl.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/config/SwaggerUIDsl.kt @@ -6,7 +6,9 @@ import io.github.smiley4.ktorswaggerui.data.DataUtils.mergeDefault import io.github.smiley4.ktorswaggerui.data.SwaggerUIData import io.github.smiley4.ktorswaggerui.dsl.OpenApiDslMarker - +/** + * Configuration for the swagger-ui + */ @OpenApiDslMarker class SwaggerUIDsl { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiHeader.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiHeader.kt index e7d9b2e..099214b 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiHeader.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiHeader.kt @@ -9,7 +9,9 @@ import io.swagger.v3.oas.models.media.Schema import kotlin.reflect.KType import kotlin.reflect.typeOf - +/** + * Describes a single header. + */ @OpenApiDslMarker class OpenApiHeader { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequest.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequest.kt index d078edd..21a34a1 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequest.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequest.kt @@ -10,7 +10,9 @@ import io.swagger.v3.oas.models.media.Schema import kotlin.reflect.KType import kotlin.reflect.typeOf - +/** + * Describes a single request. + */ @OpenApiDslMarker class OpenApiRequest { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequestParameter.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequestParameter.kt index 93f822e..41ce904 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequestParameter.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRequestParameter.kt @@ -10,7 +10,9 @@ import io.github.smiley4.ktorswaggerui.dsl.OpenApiDslMarker import io.swagger.v3.oas.models.examples.Example import io.swagger.v3.oas.models.parameters.Parameter - +/** + * Describes a single request parameter. + */ @OpenApiDslMarker class OpenApiRequestParameter( /** diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRoute.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRoute.kt index 2b2def4..c85084c 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRoute.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/routes/OpenApiRoute.kt @@ -7,6 +7,9 @@ import io.github.smiley4.ktorswaggerui.dsl.OpenApiDslMarker import io.github.smiley4.ktorswaggerui.dsl.config.OpenApiExternalDocs import io.github.smiley4.ktorswaggerui.dsl.config.OpenApiServer +/** + * Describes a single route including request and responses. + */ @OpenApiDslMarker class OpenApiRoute { diff --git a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/routing/routing.kt b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/routing/routing.kt index 3e4bf2a..ecff6b2 100644 --- a/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/routing/routing.kt +++ b/ktor-swagger-ui/src/main/kotlin/io/github/smiley4/ktorswaggerui/routing/routing.kt @@ -13,7 +13,9 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* - +/** + * Registers the route for serving an openapi-spec. When multiple specs are configured, the id of the one to serve has to be provided. + */ fun Route.openApiSpec(specId: String = PluginConfigDsl.DEFAULT_SPEC_ID) { route({ hidden = true }) { get { @@ -22,6 +24,9 @@ fun Route.openApiSpec(specId: String = PluginConfigDsl.DEFAULT_SPEC_ID) { } } +/** + * Registers the route for serving all swagger-ui resources. The path to the openapi-spec file to use has to be given. + */ fun Route.swaggerUI(apiUrl: String) { route({ hidden = true }) { get { diff --git a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OpenApiBuilderTest.kt b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OpenApiBuilderTest.kt index b805c6d..b4a3fa3 100644 --- a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OpenApiBuilderTest.kt +++ b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OpenApiBuilderTest.kt @@ -33,7 +33,6 @@ import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.maps.shouldHaveSize -import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.swagger.v3.oas.models.OpenAPI @@ -118,7 +117,7 @@ class OpenApiBuilderTest : StringSpec({ private fun exampleContext(routes: List, pluginConfig: PluginConfigDsl): ExampleContext { val pluginConfigData = pluginConfig.build(PluginConfigData.DEFAULT) return ExampleContextImpl().also { - it.addGlobal(pluginConfigData.exampleConfig) + it.addShared(pluginConfigData.exampleConfig) it.add(routes) } } diff --git a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OperationBuilderTest.kt b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OperationBuilderTest.kt index f35e072..775c562 100644 --- a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OperationBuilderTest.kt +++ b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/OperationBuilderTest.kt @@ -965,7 +965,7 @@ class OperationBuilderTest : StringSpec({ private fun exampleContext(routes: List, pluginConfig: PluginConfigDsl = defaultPluginConfig): ExampleContext { val pluginConfigData = pluginConfig.build(PluginConfigData.DEFAULT) return ExampleContextImpl().also { - it.addGlobal(pluginConfigData.exampleConfig) + it.addShared(pluginConfigData.exampleConfig) it.add(routes) } } diff --git a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/PathsBuilderTest.kt b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/PathsBuilderTest.kt index f55f767..ff5534d 100644 --- a/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/PathsBuilderTest.kt +++ b/ktor-swagger-ui/src/test/kotlin/io/github/smiley4/ktorswaggerui/builder/PathsBuilderTest.kt @@ -96,7 +96,7 @@ class PathsBuilderTest : StringSpec({ private fun exampleContext(routes: List, pluginConfig: PluginConfigDsl): ExampleContext { val pluginConfigData = pluginConfig.build(PluginConfigData.DEFAULT) return ExampleContextImpl().also { - it.addGlobal(pluginConfigData.exampleConfig) + it.addShared(pluginConfigData.exampleConfig) it.add(routes) } } diff --git a/todo.txt b/todo.txt deleted file mode 100644 index 11c5860..0000000 --- a/todo.txt +++ /dev/null @@ -1,5 +0,0 @@ -todo: - -- keep up to date with schema-kenerator features - -- wiki / documentation \ No newline at end of file