-
Notifications
You must be signed in to change notification settings - Fork 56
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 TransferTypes plugin for Generator #3171
Open
Lodin
wants to merge
16
commits into
main
Choose a base branch
from
feat/multipart-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d3a4cba
refactor: add transferTypes functionality
Lodin d06ec6f
refactor(generator-plugin-subtypes)
Lodin b28dea2
refactor: address code changes
Lodin 46c35ef
refactor(generator-plugin-client): revert some changes
Lodin 6bf0985
feat(generator-plugin-transfertypes): add transfer type plugin for Mu…
Lodin 0bc0ee4
Merge branch 'refs/heads/main' into feat/multipart-file
Lodin c7df876
fix(generator-core): remove ReadonlyDeep type
Lodin 074b0df
fix(generator-cli): remove File type import
Lodin 8b13550
fix: remove ReadonlyDeep type
Lodin 711716a
fix(generator-plugin-subtypes): address typing issue
Lodin 73d974a
chore: pin React version
Lodin dde1829
Merge branch 'refs/heads/main' into feat/multipart-file
Lodin c330705
style(parser-jvm-plugin-transfertypes): format
Lodin 4b3e616
fix(generator-cli): remove custom File reference
Lodin 42ae234
fix(generator-plugin-transfertypes): add missing dependency
Lodin 4801749
chore(react-i18n): use Vitest for testing due to CI failures
Lodin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
...nsfertypes/src/test/java/com/vaadin/hilla/parser/plugins/transfertypes/file/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.file; | ||
|
||
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 { | ||
} |
9 changes: 9 additions & 0 deletions
9
...c/test/java/com/vaadin/hilla/parser/plugins/transfertypes/file/MultipartFileEndpoint.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,9 @@ | ||
package com.vaadin.hilla.parser.plugins.transfertypes.file; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Endpoint | ||
public class MultipartFileEndpoint { | ||
public void uploadFile(MultipartFile file) { | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...s/src/test/java/com/vaadin/hilla/parser/plugins/transfertypes/file/MultipartFileTest.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,30 @@ | ||
package com.vaadin.hilla.parser.plugins.transfertypes.file; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
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; | ||
|
||
public class MultipartFileTest { | ||
private final TestHelper helper = new TestHelper(getClass()); | ||
|
||
@Test | ||
public void should_ReplaceMultipartFileClassWithLocalFileClass() | ||
throws IOException, URISyntaxException { | ||
var openAPI = new Parser() | ||
.classPath(Set.of(helper.getTargetDir().toString())) | ||
.endpointAnnotations(List.of(Endpoint.class)) | ||
.addPlugin(new BackbonePlugin()) | ||
.addPlugin(new TransferTypesPlugin()) | ||
.execute(List.of(MultipartFileEndpoint.class)); | ||
|
||
helper.executeParserWithConfig(openAPI); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...rtypes/src/test/resources/com/vaadin/hilla/parser/plugins/transfertypes/file/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,60 @@ | ||
{ | ||
"openapi" : "3.0.1", | ||
"info" : { | ||
"title" : "Hilla Application", | ||
"version" : "1.0.0" | ||
}, | ||
"servers" : [ | ||
{ | ||
"url" : "http://localhost:8080/connect", | ||
"description" : "Hilla Backend" | ||
} | ||
], | ||
"tags" : [ | ||
{ | ||
"name" : "MultipartFileEndpoint", | ||
"x-class-name" : "com.vaadin.hilla.parser.plugins.transfertypes.file.MultipartFileEndpoint" | ||
} | ||
], | ||
"paths" : { | ||
"/MultipartFileEndpoint/uploadFile" : { | ||
"post" : { | ||
"tags" : [ | ||
"MultipartFileEndpoint" | ||
], | ||
"operationId" : "MultipartFileEndpoint_uploadFile_POST", | ||
"requestBody" : { | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"type" : "object", | ||
"properties" : { | ||
"file" : { | ||
"nullable" : true, | ||
"anyOf" : [ | ||
{ | ||
"$ref" : "#/components/schemas/com.vaadin.hilla.runtime.transfertypes.File" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses" : { | ||
"200" : { | ||
"description" : "" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components" : { | ||
"schemas" : { | ||
"com.vaadin.hilla.runtime.transfertypes.File" : { | ||
"type" : "object" | ||
} | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...ntime-plugin-transfertypes/src/main/java/com/vaadin/hilla/runtime/transfertypes/File.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,4 @@ | ||
package com.vaadin.hilla.runtime.transfertypes; | ||
|
||
public record File() { | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the added
spring-web
dependency, is there a reason not to use theMultipartFile.class.getName()
instead of the string literal version of the class name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... Good question. Actually, I just followed the approach for other Spring classes in this file. Should we reconsider this approach?