Skip to content

Commit

Permalink
GH-129 Support @OpenApiName in composition API
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Dec 21, 2022
1 parent 9f7cc7b commit 44465d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fun JsonObject.createComposition(
.let { add(propertyComposition.type.propertyName, it) }
false ->
refs
.map { createJsonObjectOf("\$ref", "#/components/schemas/${it.toString().substringAfterLast(".")}") }
.map { createJsonObjectOf("\$ref", "#/components/schemas/${it.getSimpleName()}") }
.toJsonArray { add(it) }
.let { add(propertyComposition.type.propertyName, it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.javalin.openapi.JsonSchema
import io.javalin.openapi.OneOf
import io.javalin.openapi.OpenApi
import io.javalin.openapi.OpenApiContent
import io.javalin.openapi.OpenApiName
import io.javalin.openapi.OpenApiResponse
import io.javalin.openapi.processor.specification.OpenApiAnnotationProcessorSpecification
import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
Expand Down Expand Up @@ -85,7 +86,8 @@ internal class CompositionTest : OpenApiAnnotationProcessorSpecification() {
data class A(val a: Int) : Union

@DiscriminatorMappingName("class-b")
data class B(val b: String) : Union
@OpenApiName("B")
data class C(val b: String) : Union

@OpenApi(
path = "discriminator",
Expand Down

0 comments on commit 44465d3

Please sign in to comment.