Skip to content
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

Wrong discriminator value in output #69

Open
Zarquan opened this issue Oct 13, 2024 · 1 comment
Open

Wrong discriminator value in output #69

Zarquan opened this issue Oct 13, 2024 · 1 comment

Comments

@Zarquan
Copy link
Member

Zarquan commented Oct 13, 2024

getType() is ignored for JupyterNotebookBean
The the autogenerated serialization code replaces the discriminator value urn:jupyter-notebook-0.1 with the schema type name JupyterNotebook.

This used to work in earlier iterations. So it is something I've broken recently.

....
executable:
  type: "JupyterNotebook"
....

Related to the template code generated by OpenAPI.

....
@Schema(name = "AbstractExecutable", description = "Abstract base class for executables.")
@JsonIgnoreProperties(
  value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization
  allowSetters = true // allows the type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true)
@JsonSubTypes({
  @JsonSubTypes.Type(value = IvoaBinderNotebook.class, name = "urn:binder-notebook-0.1"),
  @JsonSubTypes.Type(value = IvoaDockerContainer.class, name = "urn:docker-container-0.1"),
  @JsonSubTypes.Type(value = IvoaJupyterNotebook.class, name = "urn:jupyter-notebook-0.1"),
  @JsonSubTypes.Type(value = IvoaRepo2DockerContainer.class, name = "urn:repo2docker-0.1"),
  @JsonSubTypes.Type(value = IvoaSingularContainer.class, name = "urn:singular-container-0.1")
})
....

Generated annotation comes from this template:
https://github.com/OpenAPITools/openapi-generator/blob/2838b9584b3adf0e8a5114f7c287561f4d8e068b/modules/openapi-generator/src/main/resources/Java/typeInfoAnnotation.mustache#L3-L6

@JsonIgnoreProperties(
  value = "{{{discriminator.propertyBaseName}}}", // ignore manually set {{{discriminator.propertyBaseName}}}, it will be automatically generated by Jackson during serialization
  allowSetters = true // allows the {{{discriminator.propertyBaseName}}} to be set during deserialization
)

Related issues

[BUG][JAVA] discriminator ignored during serialization #12777
OpenAPITools/openapi-generator#12777

BUG][JAVA] Error in serialization of object lists with polymorphism #18460
OpenAPITools/openapi-generator#18460

[BUG] [SPRING] legacyDiscriminatorBehavior property is always ignored #12692
OpenAPITools/openapi-generator#12692

@Zarquan
Copy link
Member Author

Zarquan commented Oct 13, 2024

Comparing the current branch (broken) with the main branch (working).

  • The annotations are the same.
  • Inheritance hierarchy is the same.

@Zarquan Zarquan changed the title Wrong type for JupyterNotebookBean Wrong discriminator value in output Oct 26, 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

No branches or pull requests

1 participant