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

feat: add support for JsonNode subclasses #2537

Merged
merged 5 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import javax.annotation.Nonnull;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.vaadin.hilla.mappedtypes.Order;
import com.vaadin.hilla.mappedtypes.Pageable;
import com.vaadin.hilla.mappedtypes.Sort;
Expand Down Expand Up @@ -44,6 +46,8 @@ public final class TransferTypesPlugin
classMap.put("com.vaadin.hilla.EndpointSubscription",
EndpointSubscription.class);
classMap.put(JsonNode.class.getName(), Object.class);
classMap.put(ObjectNode.class.getName(), Object.class);
classMap.put(ArrayNode.class.getName(), List.class);
}

public TransferTypesPlugin() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.vaadin.hilla.parser.plugins.transfertypes.jsonnode;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

@Endpoint
public class JsonNodeEndpoint {
public JsonNode echo(JsonNode node) {
public JsonNode jsonNode(JsonNode node) {
return node;
}

public ObjectNode objectNode(ObjectNode node) {
return node;
}

public ArrayNode arrayNode(ArrayNode node) {
return node;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.vaadin.hilla.parser.plugins.transfertypes.jsonnode;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE_USE })
public @interface Nonnull {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.vaadin.hilla.parser.plugins.transfertypes.jsonnode;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE_USE })
public @interface Nullable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,82 @@
}
],
"paths" : {
"/JsonNodeEndpoint/echo" : {
"/JsonNodeEndpoint/arrayNode" : {
"post" : {
"tags" : [
"JsonNodeEndpoint"
],
"operationId" : "JsonNodeEndpoint_echo_POST",
"operationId" : "JsonNodeEndpoint_arrayNode_POST",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "object",
"properties" : {
"node" : {
"type" : "array",
"nullable" : true
}
}
}
}
}
},
"responses" : {
"200" : {
"description" : "",
"content" : {
"application/json" : {
"schema" : {
"type" : "array",
"nullable" : true
}
}
}
}
}
}
},
"/JsonNodeEndpoint/jsonNode" : {
"post" : {
"tags" : [
"JsonNodeEndpoint"
],
"operationId" : "JsonNodeEndpoint_jsonNode_POST",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "object",
"properties" : {
"node" : {
"type" : "object"
}
}
}
}
}
},
"responses" : {
"200" : {
"description" : "",
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
}
}
}
}
}
}
},
"/JsonNodeEndpoint/objectNode" : {
"post" : {
"tags" : [
"JsonNodeEndpoint"
],
"operationId" : "JsonNodeEndpoint_objectNode_POST",
"requestBody" : {
"content" : {
"application/json" : {
Expand Down
Loading