-
Notifications
You must be signed in to change notification settings - Fork 57
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: show autoform non-rendered property errors #2833
Open
krissvaa
wants to merge
7
commits into
main
Choose a base branch
from
fix/crud-ignored-property-errors
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2248e82
Shows hidden property errors to the form and scroll to it
krissvaa a8d91e7
Resolve jakarta persistence id and version annotations as nullable by…
krissvaa d38a409
fix formatting
krissvaa 36ab823
Fix type check
krissvaa 88a4bef
Add test for nonnull and nullable hierarchy
krissvaa 7ae20c5
Add test for nonnull and nullable hierarchy
krissvaa 74b4a76
fix formatting
krissvaa 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
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
...ugin-nonnull/src/test/java/com/vaadin/hilla/parser/plugins/nonnull/nullable/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.nonnull.nullable; | ||
|
||
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 { | ||
} |
11 changes: 11 additions & 0 deletions
11
...nnull/src/test/java/com/vaadin/hilla/parser/plugins/nonnull/nullable/EndpointExposed.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.nonnull.nullable; | ||
|
||
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 EndpointExposed { | ||
} |
20 changes: 20 additions & 0 deletions
20
...null/src/test/java/com/vaadin/hilla/parser/plugins/nonnull/nullable/NullableEndpoint.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,20 @@ | ||
package com.vaadin.hilla.parser.plugins.nonnull.nullable; | ||
|
||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Version; | ||
|
||
@Endpoint | ||
public class NullableEndpoint { | ||
|
||
public NullableFieldModel nullableFieldModel( | ||
NullableFieldModel nullableFieldModel) { | ||
return nullableFieldModel; | ||
} | ||
|
||
public static class NullableFieldModel { | ||
@Id | ||
public String id; | ||
@Version | ||
public Long version; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...-nonnull/src/test/java/com/vaadin/hilla/parser/plugins/nonnull/nullable/NullableTest.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,48 @@ | ||
package com.vaadin.hilla.parser.plugins.nonnull.nullable; | ||
|
||
import com.vaadin.hilla.parser.core.Parser; | ||
import com.vaadin.hilla.parser.plugins.backbone.BackbonePlugin; | ||
import com.vaadin.hilla.parser.plugins.nonnull.AnnotationMatcher; | ||
import com.vaadin.hilla.parser.plugins.nonnull.NonnullPlugin; | ||
import com.vaadin.hilla.parser.plugins.nonnull.NonnullPluginConfig; | ||
import com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi.NullableNonNullEndpoint; | ||
import com.vaadin.hilla.parser.plugins.nonnull.test.helpers.TestHelper; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.Set; | ||
|
||
public class NullableTest { | ||
private final TestHelper helper = new TestHelper(getClass()); | ||
|
||
@Test | ||
public void should_ApplyNullableAnnotation() | ||
throws IOException, URISyntaxException { | ||
var plugin = new NonnullPlugin(); | ||
plugin.setConfiguration(new NonnullPluginConfig()); | ||
|
||
var openAPI = new Parser().classLoader(getClass().getClassLoader()) | ||
.classPath(Set.of(helper.getTargetDir().toString())) | ||
.endpointAnnotation(Endpoint.class.getName()) | ||
.endpointExposedAnnotation(EndpointExposed.class.getName()) | ||
.addPlugin(new BackbonePlugin()).addPlugin(plugin).execute(); | ||
|
||
helper.executeParserWithConfig(openAPI); | ||
} | ||
|
||
@Test | ||
public void annotationMatcher_shouldHaveDefaultConstructorAndSetter() { | ||
// to enable maven initialize instances of AnnotationMatcher from | ||
// pom.xml configurations, properly, it should have the default | ||
// constructor and setter methods: | ||
AnnotationMatcher annotationMatcher = new AnnotationMatcher(); | ||
annotationMatcher.setName("name"); | ||
annotationMatcher.setScore(100); | ||
annotationMatcher.setMakesNullable(true); | ||
Assertions.assertEquals("name", annotationMatcher.getName()); | ||
Assertions.assertEquals(100, annotationMatcher.getScore()); | ||
Assertions.assertTrue(annotationMatcher.doesMakeNullable()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../com/vaadin/hilla/parser/plugins/nonnull/nullable/nonNullApi/NullableNonNullEndpoint.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,26 @@ | ||
package com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi; | ||
|
||
import com.vaadin.hilla.parser.plugins.nonnull.nullable.Endpoint; | ||
import jakarta.annotation.Nonnull; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Version; | ||
|
||
@Endpoint | ||
public class NullableNonNullEndpoint { | ||
|
||
public NullableNonNullFieldModel nullableNonNullFieldModel( | ||
NullableNonNullFieldModel nullableNonNullFieldModel) { | ||
return nullableNonNullFieldModel; | ||
} | ||
|
||
public static class NullableNonNullFieldModel { | ||
public String required; | ||
@Id | ||
public String id; | ||
@Version | ||
public Long version; | ||
@Version | ||
@Nonnull | ||
public Long notNullVersion; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...c/test/java/com/vaadin/hilla/parser/plugins/nonnull/nullable/nonNullApi/package-info.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 @@ | ||
@NonNullApi | ||
package com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi; | ||
|
||
import org.springframework.lang.NonNullApi; |
150 changes: 150 additions & 0 deletions
150
...-nonnull/src/test/resources/com/vaadin/hilla/parser/plugins/nonnull/nullable/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,150 @@ | ||
{ | ||
"openapi" : "3.0.1", | ||
"info" : { | ||
"title" : "Hilla Application", | ||
"version" : "1.0.0" | ||
}, | ||
"servers" : [ | ||
{ | ||
"url" : "http://localhost:8080/connect", | ||
"description" : "Hilla Backend" | ||
} | ||
], | ||
"tags" : [ | ||
{ | ||
"name" : "NullableEndpoint", | ||
"x-class-name" : "com.vaadin.hilla.parser.plugins.nonnull.nullable.NullableEndpoint" | ||
}, | ||
{ | ||
"name" : "NullableNonNullEndpoint", | ||
"x-class-name" : "com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi.NullableNonNullEndpoint" | ||
} | ||
], | ||
"paths" : { | ||
"/NullableEndpoint/nullableFieldModel" : { | ||
"post" : { | ||
"tags" : [ | ||
"NullableEndpoint" | ||
], | ||
"operationId" : "NullableEndpoint_nullableFieldModel_POST", | ||
"requestBody" : { | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"type" : "object", | ||
"properties" : { | ||
"nullableFieldModel" : { | ||
"nullable" : true, | ||
"anyOf" : [ | ||
{ | ||
"$ref" : "#/components/schemas/com.vaadin.hilla.parser.plugins.nonnull.nullable.NullableEndpoint$NullableFieldModel" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses" : { | ||
"200" : { | ||
"description" : "", | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"nullable" : true, | ||
"anyOf" : [ | ||
{ | ||
"$ref" : "#/components/schemas/com.vaadin.hilla.parser.plugins.nonnull.nullable.NullableEndpoint$NullableFieldModel" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/NullableNonNullEndpoint/nullableNonNullFieldModel" : { | ||
"post" : { | ||
"tags" : [ | ||
"NullableNonNullEndpoint" | ||
], | ||
"operationId" : "NullableNonNullEndpoint_nullableNonNullFieldModel_POST", | ||
"requestBody" : { | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"type" : "object", | ||
"properties" : { | ||
"nullableNonNullFieldModel" : { | ||
"anyOf" : [ | ||
{ | ||
"$ref" : "#/components/schemas/com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi.NullableNonNullEndpoint$NullableNonNullFieldModel" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses" : { | ||
"200" : { | ||
"description" : "", | ||
"content" : { | ||
"application/json" : { | ||
"schema" : { | ||
"anyOf" : [ | ||
{ | ||
"$ref" : "#/components/schemas/com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi.NullableNonNullEndpoint$NullableNonNullFieldModel" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components" : { | ||
"schemas" : { | ||
"com.vaadin.hilla.parser.plugins.nonnull.nullable.NullableEndpoint$NullableFieldModel" : { | ||
"type" : "object", | ||
"properties" : { | ||
"id" : { | ||
"type" : "string", | ||
"nullable" : true | ||
}, | ||
"version" : { | ||
"type" : "integer", | ||
"format" : "int64", | ||
"nullable" : true | ||
} | ||
} | ||
}, | ||
"com.vaadin.hilla.parser.plugins.nonnull.nullable.nonNullApi.NullableNonNullEndpoint$NullableNonNullFieldModel" : { | ||
"type" : "object", | ||
"properties" : { | ||
"required" : { | ||
"type" : "string" | ||
}, | ||
"id" : { | ||
"type" : "string", | ||
"nullable" : true | ||
}, | ||
"version" : { | ||
"type" : "integer", | ||
"format" : "int64", | ||
"nullable" : true | ||
}, | ||
"notNullVersion" : { | ||
"type" : "integer", | ||
"format" : "int64" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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.
Those fields look nullable by default, unless I'm missing something. You should probably test them under a
@NonNullApi
annotation.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.
I should, but I should also check that they are indeed nullable without any other annotation.
I will add another test.