ktor-swagger-ui icon indicating copy to clipboard operation
ktor-swagger-ui copied to clipboard

Global Type Replacement

Open DebitCardz opened this issue 6 months ago • 4 comments

Hey! I was wondering if it was possible to globally replace Instant to a int64 when it's converted to the OpenAPI Spec, when we send data from our service to whatever is consuming it we usually send Instants as Milliseconds instead of a string, so it'd be useful to just have it globally convert to a int64.

I read #44 but I don't think it's quite what I need.

Here is my current configuration

fun Application.configureSwaggerUi() {
    install(SwaggerUI) {
        swagger {
            displayOperationId = true
        }

        info {
            title = "API"
            version = "latest"
            description = "The auto-generated API documentation for the API"
        }

        security {
            securityScheme("account") {
                description = "Typically used for Account Authentication on the Dashboard"
                type = AuthType.HTTP
                scheme = AuthScheme.BEARER
                bearerFormat = "JWT"
            }

            securityScheme("token") {
                description = "Used for having Applications interact with the Ingot API"
                type = AuthType.HTTP
                scheme = AuthScheme.BEARER
                bearerFormat = "API Token"
            }
        }

        server {
            url = "http://localhost:8080"
            description = "Development Server"
        }

        // kotlinx support
        schemas {
            generator = { type ->
                type
                    .processKotlinxSerialization()
                    .generateSwaggerSchema()
                    .withAutoTitle(TitleType.FULL)
                    .compileInlining()
            }
        }

        ignoredRouteSelectors = ignoredRouteSelectors + RateLimitRouteSelector::class
    }
}

Thank you!

DebitCardz avatar Aug 07 '24 10:08 DebitCardz