Skip to content

Support auto-schema generation for JSON duality view #3599

@andriy-dmytruk

Description

@andriy-dmytruk

Issue description

The idea is to extend support for JSON Duality View with similar features that exist for other entities.

An example of extended class could be:

AuthorView.java
@JsonView(
   value = "AUTHOR_BOOKS", // the name of the duality view
   entity = Author.class, // The base entity
   with = { UPDATE, INSERT, DELETE } // The operations of the view specified in SQL CREATE query
)public record AuthorView(
    @Id @GeneratedValue(GeneratedValue.Type.IDENTITY) @Nullable
    Long authorId,
    @MappedProperty("name") //author.name will be used to fill this property
    String author,
    @Relation(Relation.Kind.ONE_TO_MANY)
    List<AuthorBookView> books
) {}

@JsonSubView(
    entity = Book.class // The base entity
)
record AuthorBookView(
    String name
) {}

This would require modifications to the current @JsonView annotation.

Since micronaut-data already supports operations on an existing JSON duality view, improvement would be to create duality views automatically using the SchemaGenerator micronaut feature. See detailed pointers below

@ZdravDimOracle is working on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions