Skip to content

fix for #804 + java interface discriminator mapping fix #1224

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

Merged

Conversation

OsztosA
Copy link
Contributor

@OsztosA OsztosA commented Dec 3, 2023

FIX for #804
Added support of discriminator mapping for Java interfaces too.
The current template does not use the discriminator defined in the Openapi definition file.

The implemented solution generate from this definition:

    "discriminator": {
      "propertyName": "aCustomProperty",
      "mapping": {
        "typeA": "#/components/schemas/classA",
        "typeB": "#/components/schemas/classB",
        "typeC": "#/components/schemas/classC"
      }
    },

this interface

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "aCustomProperty")
@JsonSubTypes({
@JsonSubTypes.Type(value = ClassA.class, name = "typeA"),
@JsonSubTypes.Type(value = ClassB.class, name = "typeB"),
@JsonSubTypes.Type(value = ClassC.class, name = "typeC")
})
public interface Item {

For more details see GeneratorResultTestJava.interfaceWithCustomDiscriminator test.

The CodegenModel in "swagger-codegen" also had to be changed, that PR must be merged first: getSubTypeName() in CodegenModel

@OsztosA OsztosA changed the title Feature/java interface discriminator fix for #804 + java interface discriminator mapping fix Dec 9, 2023
@HugoMario
Copy link
Contributor

Hey @OsztosA
Thanks a lot for this PR, can you please fix the import reverting back the changes you made on it in order to merge this?

@HugoMario HugoMario self-assigned this Feb 13, 2024
@HugoMario HugoMario merged commit ba23ec1 into swagger-api:master Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants