-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Map JsonNode to Object * Improve test * Test nullability * Remove nullability as Object is translated to unknown --------- Co-authored-by: Anton Platonov <platosha@gmail.com>
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...rtypes/src/test/java/com/vaadin/hilla/parser/plugins/transfertypes/jsonnode/Endpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
public @interface Endpoint { | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/test/java/com/vaadin/hilla/parser/plugins/transfertypes/jsonnode/JsonNodeEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.vaadin.hilla.parser.plugins.transfertypes.jsonnode; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
@Endpoint | ||
public class JsonNodeEndpoint { | ||
public JsonNode echo(JsonNode node) { | ||
return node; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...es/src/test/java/com/vaadin/hilla/parser/plugins/transfertypes/jsonnode/JsonNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.vaadin.hilla.parser.plugins.transfertypes.jsonnode; | ||
|
||
import com.vaadin.hilla.parser.core.Parser; | ||
import com.vaadin.hilla.parser.plugins.backbone.BackbonePlugin; | ||
import com.vaadin.hilla.parser.plugins.transfertypes.TransferTypesPlugin; | ||
import com.vaadin.hilla.parser.plugins.transfertypes.test.helpers.TestHelper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.Set; | ||
|
||
public class JsonNodeTest { | ||
private final TestHelper helper = new TestHelper(getClass()); | ||
|
||
@Test | ||
public void should_ReplaceJsonNodeClassWithObject() | ||
throws IOException, URISyntaxException { | ||
var openAPI = new Parser().classLoader(getClass().getClassLoader()) | ||
.classPath(Set.of(helper.getTargetDir().toString())) | ||
.endpointAnnotation(Endpoint.class.getName()) | ||
.addPlugin(new BackbonePlugin()) | ||
.addPlugin(new TransferTypesPlugin()).execute(); | ||
|
||
helper.executeParserWithConfig(openAPI); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...es/src/test/resources/com/vaadin/hilla/parser/plugins/transfertypes/jsonnode/openapi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"openapi" : "3.0.1", | ||
"info" : { | ||
"title" : "Hilla Application", | ||
"version" : "1.0.0" | ||
}, | ||
"servers" : [ | ||
{ | ||
"url" : "http://localhost:8080/connect", | ||
"description" : "Hilla Backend" | ||
} | ||
], | ||
"tags" : [ | ||
{ | ||
"name" : "JsonNodeEndpoint", | ||
"x-class-name" : "com.vaadin.hilla.parser.plugins.transfertypes.jsonnode.JsonNodeEndpoint" | ||
} | ||
], | ||
"paths" : { | ||
"/JsonNodeEndpoint/echo" : { | ||
"post" : { | ||
"tags" : [ | ||
"JsonNodeEndpoint" | ||
], | ||
"operationId" : "JsonNodeEndpoint_echo_POST", | ||
"requestBody" : { | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"type" : "object", | ||
"properties" : { | ||
"node" : { | ||
"type" : "object" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses" : { | ||
"200" : { | ||
"description" : "", | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"type" : "object" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |