SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI
Apache License 2.0
150 stars 25 forks source link

Unable to use schemasInComponentSection = true #87

Closed Devashree closed 4 months ago

Devashree commented 5 months ago

install(SwaggerUI) {

            pathFilter = { _, url ->
                val path = url.joinToString("/")
                !EXCLUDED_PATHS.any { path.contains(it) }
            }
            swagger {
                // schemasInComponentSection = true
                forwardRoot = false
                swaggerUrl = "swagger"
                onlineSpecValidator()
                displayOperationId = true
                showTagFilterInput = true
                syntaxHighlight = SwaggerUiSyntaxHighlight.MONOKAI
            }
            info {
                title = "Example Api"
                version = "0.0.1"
                description = "BFF"
            }
            server {
                url = "http://localhost:8081"
                description = ""
            }

}

currently using 2.7.3 version . want to generate ref for each dataModel. I am not sure how to use schemasInComponent = true to help generate current schema ref. Example: Currently generated:

                  "$ref" : "#/components/schemas/com.example.workspace.api.models.Response<kotlin.collections.List<com.example.business.logic.datamodels.InfoResponse>>"
                }```
         Expected: 
 ``` "schema" : {
                  "$ref" : "#InfoResponse>>"
                }
SMILEY4 commented 5 months ago

Hi, The option schemasInComponent was removed with version 2.0. What gets added to the components section is mainly determined by the configuration of the json-schema-generator (more info here: Customizing the default Encoder). However, i think the options may be somewhat limited and may already be configured to reference schemas where possible. I am already working on improvements to schema generation, but that may still take some time to be completly ready.