File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed
main/kotlin/com/papsign/ktor/openapigen Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.papsign.ktor.openapigen.modules.CachingModuleProvider
44import com.papsign.ktor.openapigen.modules.schema.*
55import com.papsign.ktor.openapigen.openapi.ExternalDocumentation
66import com.papsign.ktor.openapigen.openapi.OpenAPI
7+ import com.papsign.ktor.openapigen.openapi.Schema
78import com.papsign.ktor.openapigen.openapi.Schema.SchemaRef
89import com.papsign.ktor.openapigen.openapi.Server
910import io.ktor.application.ApplicationCallPipeline
@@ -85,14 +86,17 @@ class OpenAPIGen(
8586 }
8687 if (predefined != null )
8788 return predefined
88- schemas.getOrPut(type) {
89- val (name, schema) = super .get(type, master)
90- schemas[type] = schema
91- names[type] = name
92- api.components.schemas[name] = schema
93- schema
89+ val current = schemas[type]
90+ if (current != null ) {
91+ val name = names[type]!!
92+ return NamedSchema (name, SchemaRef <Any >(" #/components/schemas/$name " ))
9493 }
95- val name = names[type]!!
94+ val (name, schema) = super .get(type, master)
95+ if (schema is Schema .SchemaArr <* >) return NamedSchema (name, schema)
96+
97+ schemas[type] = schema
98+ names[type] = name
99+ api.components.schemas[name] = schema
96100 return NamedSchema (name, SchemaRef <Any >(" #/components/schemas/$name " ))
97101 }
98102 }
Original file line number Diff line number Diff line change @@ -139,6 +139,15 @@ object TestServer {
139139 respond(StringResponse (params.a))
140140 }
141141
142+ route(" list" ) {
143+ get<StringParam , List <StringResponse >>(
144+ info(" String Param Endpoint" , " This is a String Param Endpoint" ),
145+ example = listOf (StringResponse (" Hi" ))
146+ ) { params ->
147+ respond(listOf (StringResponse (params.a)))
148+ }
149+ }
150+
142151 route(" sealed" ) {
143152 post<Unit , Base , Base >(
144153 info(" Sealed class Endpoint" , " This is a Sealed class Endpoint" ),
You can’t perform that action at this time.
0 commit comments