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

[Fix #461] oneOf options must inherit union class common part #464

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

fjtirado
Copy link
Collaborator

@fjtirado fjtirado commented Nov 11, 2024

Fix #461
This slightly change the generated code public API.
Properties in POJOs that contains both properties and oneOf are moved to a parent class which is inherited by the oneOf alternative classes. This is done that way because reading two nested classes from the same json node is pretty tricky and will move the complexity to the generated serializer/deserializer (reinventing Jackson essentially)

Just one example, previously we have

public class Schema implements Serializable, OneOfValueProvider
{

    /**
     * SchemaFormat
     * <p>
     * The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.
     * 
     */
    @JsonProperty("format")
    @JsonPropertyDescription("The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.")
    private String format = "json";
    private final static long serialVersionUID = 7823919531911950336L;
    private Object value;
    private SchemaInline schemaInline;
    private SchemaExternal schemaExternal;

after this PR, we will have

@JsonSerialize(using = SchemaUnionSerializer.class)
@JsonDeserialize(using = SchemaUnionDeserializer.class)
public class SchemaUnion
    implements OneOfValueProvider<Schema>
{

    private Schema value;
    private SchemaInline schemaInline;
    private SchemaExternal schemaExternal;

and

public class Schema implements Serializable
{

    /**
     * SchemaFormat
     * <p>
     * The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.
     * 
     */
    @JsonProperty("format")
    @JsonPropertyDescription("The schema's format. Defaults to 'json'. The (optional) version of the format can be set using `{format}:{version}`.")
    private String format = "json";
    private final static long serialVersionUID = 7823919531911950336L;




…ommon part

Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
@fjtirado fjtirado merged commit c5e309c into serverlessworkflow:main Nov 12, 2024
2 checks passed
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.

Failing to recognize format property for schema
2 participants