Skip to content

Nested oneOf and allOf when using oneOf with @JsonSubTypes #2655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghovhannesVM opened this issue Jul 23, 2024 · 4 comments
Closed

Nested oneOf and allOf when using oneOf with @JsonSubTypes #2655

ghovhannesVM opened this issue Jul 23, 2024 · 4 comments

Comments

@ghovhannesVM
Copy link

Describe the bug
When I use @JsonSubTypes with @Schema(oneOf = {..}), the model schema shows infinite nested oneOf and allOf. When I remove @JsonSubTypes from the parent model, everything works well. Am i doing something wrong or is this expected behaviour ?

Expected behavior
The expected behavior is to show only the oneOf field. After selecting one of the child classes, it should stop expanding.

Screenshots
The structure of the model
Screenshot 2024-07-23 at 18 10 25

The output
Screenshot 2024-07-23 at 18 13 47

Versions

  • springdoc-openapi-starter-webmvc-ui 2.1.0
@LouisXhaferi
Copy link

LouisXhaferi commented Jul 26, 2024

Also mentioned in #2575 and #2577, which have since been closed

This is still broken in 2.6.0

We ran into a similar (maybe the same?) issue when trying to use polymorphic types, like:

@JsonTypeInfo(use = NAME, include = PROPERTY, property = DISCRIMINATOR_PROPERTY)
@JsonSubTypes(
    Type(value = Activate::class, name = ACTIVATE)
)
@Schema(
    subTypes = [Activate::class],
    oneOf = [Activate::class],
    discriminatorProperty = DISCRIMINATOR_PROPERTY,
    discriminatorMapping = [
        DiscriminatorMapping(value = ACTIVATE, schema = Activate::class)
    ]
)
sealed interface PolymorphicEvent {
    @Schema(requiredProperties = [DISCRIMINATOR_PROPERTY])
    @SchemaProperty(name = DISCRIMINATOR_PROPERTY, schema = Schema(allowableValues = [ACTIVATE]))
    data object Activate : PolymorphicEvent

    companion object {
        const val DISCRIMINATOR_PROPERTY = "type"
        const val ACTIVATE = "ACTIVATE"
    }
}

Defining this in 2.3.0 would work, but totally broke our Schema view in SwaggerUI after 2.5.0, where the oneOf definition just references itself recursively forever. (This might even be worth a second issue)

image

@ilaoud
Copy link

ilaoud commented Jul 26, 2024

I have the same probleme in 2.6.0

@Nhattd97
Copy link

Nhattd97 commented Sep 4, 2024

Do you have any updates on this? Thanks!

@bnasslahsen
Copy link
Collaborator

@ghovhannesVM,

Not reproducible.
Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

This ticket will be closed, but can be reopened if your provide the reproducible sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants